Our great sponsors
-
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.
-
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)
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.
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).
This one is gold, and an alternative I use when working with other languages is quicktype