January 2018
Intermediate to advanced
434 pages
14h 1m
English
Now, let's follow these steps to parse JSON data using Gson. For example, we will use a raw string here to keep things simple:
val jsonStr=""" { "name": "Aanand Shekhar", "age": 21, "isAwesome": true }""".trimIndent()
data class Information(val name:String,val age:Int, val isAwesome:Boolean)
val information:Information= Gson().fromJson<Information>(jsonStr,Information::class.java)
Now you can use it just like a Kotlin object.
Read now
Unlock full access