https://kotlinlang.org logo
Title
d

Daniele B

03/03/2023, 12:52 PM
How can I serialize a Map<String,Any> into a JSON string?
e

efemoney

03/03/2023, 1:11 PM
It looks like you need to pass a serializer
d

Daniele B

03/03/2023, 1:14 PM
it’s just a simple Map<String,Any> which kind of serializer should I use?
e

ephemient

03/03/2023, 1:16 PM
you cannot safely serialize
Any
d

Daniele B

03/03/2023, 1:17 PM
what do you recommend to convert a
Map<String,Any>
into a JSON string?
in Golang, you can marshall a
map[string]interface{}
to a JSON string with a single line
j

jw

03/03/2023, 1:32 PM
Convert it to JsonObject or write a serializer that does runtime contextual lookup of serializers for the values
d

Daniele B

03/03/2023, 1:37 PM
Oh, thanks! I wasn’t aware there was a JsonObject 👍
a

Adam S

03/03/2023, 3:03 PM