Upgrading to Moshi
summary
Compares Moshi to Gson with concrete migration notes: Moshi keeps a streaming and object API, adds selectName/selectString and Options to avoid allocating field-name strings, and reuses Okio buffers to cut overhead; the library adds failOnUnknown for strict debugging, requires registering adapters for platform types, and throws on unknown enums instead of returning null. Adapter creation is more expensive but reusable, Moshi adds no field‑naming policy, adds ~112 KB (on top of Okio), and supports Retrofit converter tricks and AutoValue-Moshi for incremental upgrades.
AI-written summary · about
chapters (11)
- 0:00Introduction to Moshi upgrade
- 1:17Why switch from GSON to Moshi
- 8:08Key API differences overview
- 12:50Streaming API changes
- 15:42Object mapping API updates
- 18:55Type token replacement with Types
- 21:29JSON qualifiers for custom adapters
- 23:59Simplified adapter creation
- 25:46Handling polymorphic types
- 28:59Step-by-step migration tips
- 31:07Resources and next steps








