Hey all, I'm looking for a low-level JSON library ...
# multiplatform
b
Hey all, I'm looking for a low-level JSON library like klaxon that works in a MPP. (Unfortunately I'm dealing with a nasty REST API and simple serialization isn't really flexible enough.) Any suggestions?
d
Kotlinx.serialization?
b
Yeah, I've been looking through the documentations, but there doesn't seems to be a way to manually create a JsonObject by hand.
c
I saw this repo the other day which looked interesting and might be what you need, though I haven’t actually tried it https://github.com/kittinunf/Forge
g
it can be created by json{} builder as well
☝️ 1
b
@gabin Looks promising, I can't seem to find any documentation on that. Where can I find the builder?
g
json { "additional key" to "value" }
b
Hmmm, that's interesting. Just trying that out now. So it's basically converted a map to a JsonObject? I'm new to kotlin, which lines in the file you like do this?
(I'm just wondering, so that I can find clever features like this in the future.)
g
it’s not basically a map. It makes json object from key-value pairs
val jsonBody = json { "user" to user, "email" to email }
You can see examples of json creation at the header of Json.kt file or search through kotlinx.serialization docs
b
Ok, cool. Admittedly, I couldn't find any examples of this anywhere in the docs beyond that brief example in the source files.
Thanks for the help though!