This endpoint returns a strongly typed campaign, and I wanted to represent this in JSON. In this post I’ll walk you through an example of how I configured KotlinX Serialization to work for my use case. While all of those libraries are great, I had a requirement of creating a multi-platform library, and went with KotlinX Serialization. There are a bunch of options for serializing JSON in Java like Moshi, Gson and Jackson. I wanted to serialize these sealed interface Kotlin models to/from JSON over HTTP. I heavily use sealed interfaces to model result objects in Kotlin as they allow me to create a type of classes that can be handled using exhaustive when statements, similar to an enum, but also each type can contain its own properties.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |