Help parsing JSON with Retrofit & Moshi

This page summarizes the projects mentioned and recommended in the original post on /r/Kotlin

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • Moshi

    A modern JSON library for Kotlin and Java.

  • However i am getting an error "Expected BEGIN-ARRAY but was BEGIN-OBJECT at $". Looking over the moshi documentation (https://github.com/square/moshi) I think I need to use an adapter as my JSON response starts with "{ }" not the expected "[ ]". I am just struggling to understand how to implement the adapter as I think the built in adapter should work.

  • ChargeMyCar

    Remake in Kotlin using databinding, lifecyle awareness, database & MVVM Design Pattern

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • JSONToKotlinClass

    Intellij Idea, Android Studio plugin for generating Kotlin data classes from JSON. Helps to avoid writing boilerplate code for model classes. Supports annotations for Gson, Moshi, Jackson. (by Mighty16)

  • Have you ever heard of a Android Studio plugin called "Kotlin Data Class File from JSON?" If not you should check out. It generates your data class for you all you have to do is copy and paste the JSON you need to convert and remember to set the class name you want, and also click the Advanced tab set it to whichever converter you're using (Gson, Moshi, kotlinx.serialization, etc).

  • Paste JSON as Code • quicktype

    Xcode extension to paste JSON as Swift, Objective-C, and more

  • This one is gold, and an alternative I use when working with other languages is quicktype

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts