I am not able to convert a JSON Array into a GroupModel
array. Below is the JSON I used:
[{
\"description\":\"My expense to others\",
\"items\"
I have found a solution that is actually working on Android with Kotlin for parsing JSON arrays of a given class. The solution of @Aravindraj didn't really work for me.
val fileData = "your_json_string"
val gson = GsonBuilder().create()
val packagesArray = gson.fromJson(fileData , Array::class.java).toList()
So basically, you only need to provide a class (YourClass
in the example) and the JSON string. GSON will figure out the rest.
The Gradle dependency is:
implementation 'com.google.code.gson:gson:2.8.6'