
Moshi has Code-gen adapter for Kotlin, This is great! With help of annotations, you make the Serialization/Deserialization much faster and bypass the old slow reflection method that Gson uses!.
Moshi has built-in support for polymorphic datatypes which also has fallback support for unknown types!.
Moshi has a newBuilder() API which can be used to create new adapters from upstream adapters, Something similar to OkHttp or Okio builders, This is super helpful because you can create separate adapters so you don’t end up with having a god adapter which knows how to parse 1K+ models.
Moshi has better and more human-readable serialization failed messages, This is a huge plus when the app’s published and you receive weird stack traces that you have no idea what you should do about. Custom adapters or Contextual Deserialization which leads to neat features that cause less boilerplate code ( Lazy adapters). You can create annotations of your own to customize parsing of a field in your JSON data, ( int colour ). Moshi offers better and more modern API you can do neat things using this super powerful API.Īnnotations are called “first-class part” Moshi, This allows you to put some information in them which leads to more fine-grained and contextual deserialization. Let’s review some of Moshi’s features: ✅ Better API: And man, That’s lovely! It’s modern, Kotlin friendly, fast, reliable with lots of features. So let’s suppose Gson’s dead, Where should we go from here? We can continue using Gson forever, it’s working! but for the curious developers out there and Kotlin lovers, there’s Moshi as well! So let’s see What’s Moshi and why? Moshi, Who?Ī modern JSON library for Kotlin and Java.