https://kotlinlang.org logo
g

gmariotti

07/02/2020, 8:34 AM
Hi folks, apologies in advances for the not “kotlin specific” question. Does anyone knows if it is possible to set the mapper to write nested json as a string? For example, a map like
mapOf("key" to mapOf("innerKey" to "value"))
serialized as
{ "key": "{\"innerKey\": \"value\"}" }
instead of
{"key": {"innerKey": "value"}}
a

araqnid

07/02/2020, 9:38 AM
I don’t think there’s a simple way to configure something like that, especially if your data model is just Maps. In a class-based model, you could annotate
@JsonSerialize
at a specific point and write a serializer/converter to marshal the value as a JSON string there.
g

gmariotti

07/02/2020, 9:43 AM
Thanks 🙏. I imagined that was the case, but still worth a try asking
3 Views