# getting-started

Colton Idle

12/16/2021, 9:57 AM
I have a simple app that makes a simple network request to get json. How do I convert that into an object without any 3rd party deps? I typically use gson or moshi for this sort of thing, but I don't think it's worth bringing in an entire library for this single network call. I know in java we used to just use some really bad Json apis, but I wonder if kotlin has anything else out of the box.

Colton Idle

12/16/2021, 10:10 AM
I've also heard of kotlinx.serialization, but I thought it was "similar" to moshi/gson where it's an additional library.


12/16/2021, 10:13 AM
It is, but I dont think, you want parse Json manually? So you would need some library, and Kotlinx serializiation does not use reflection at runtime, but a compiler plugin at compile time. BTW Gson is dead.

Colton Idle

12/16/2021, 10:34 AM
yeah. like i said. I typically use moshi, but bringing in a library for it seemed crazy, just to map like 4 fields in a data class. I'll try kotlinx.serialization. If anyone else has another suggestion. Let me know. Thanks!

Matteo Mirk

12/16/2021, 10:36 AM
but bringing in a library for it seemed crazy, just to map like 4 fields in a data class
best wishes writing your JSON parser 😉
jokes aside, for a simple case like this maybe you just need a parser and then do manual binding to your domain type, so you can shrink dependencies. But anyway, kotlinx.serialization is your best choice

Colton Idle

12/16/2021, 10:52 AM
thanks. I've used org.json when I needed a quick object in my java android code, so I was wondering if there was anything like that, but it sounds like kotlinx it is!
👍 1


12/16/2021, 11:17 AM
it depends, I still think it depends on your target. if jvm, jackson or gson are still less pain than kotlinx serialization, but if you want to target also js or ios, then kotlinx