public fun SharedPayload.encodeToJson(): JsonElement = SharedPayloadJson.encodeToJsonElement(
SharedSharedPayloadFromBuilder.serializer(), this as SharedSharedPayloadFromBuilder
How can i disable the escaping when im dealing with strings?
n
Nikky
03/11/2022, 3:11 PM
i guess you want to have data be json inside the
SharedPayload
try making that not a string but a
JsonLiteral
or more specifically a
JsonObject
then it will serialize like you want
g
George
03/11/2022, 3:22 PM
Hi nikky, thanks for the info!. I am trying to make it work with type Any for data, do you think im better of with jsobject or should i stick with generics? FYI my motivasion to work with any type is to make it work also with other types (e.g. proto).
On second thought maybe is it ok for me to store everything as jsonObjects then serialize my
sharedpayload
as i wish, for example either to jsonElement or either to Proto?
n
Nikky
03/12/2022, 12:43 PM
Stick to JsonElement at least
Nikky
03/12/2022, 12:46 PM
If you also use proto or cbor, maybe you need Any and somehow the serializer its using, but that gets very complicated quickly
g
George
03/13/2022, 9:28 AM
indeed that's the case, it got very complicated 😛 thanks for help though, appreciate it