so I have this JSON in string format:
[
"1.0",
"1.1",
"1.2"
]
but I need to convert it to ArrayList In Kotlin ? I have tried to find, but most of the answer are in Java. if using gson in Java maybe it will be like this. but I am a beginner and I failed to convert the code below to Kotlin
Gson gson = new GsonBuilder().create();
ArrayList<String> theList = gson.fromJson(stringObject, new TypeToken<ArrayList<String>>(){}.getType())
what should I do to convert that json string to array list in Kotlin ?
Maybe this is the kotlin code you want, converted from your Java code:
val gson = GsonBuilder().create()
val theList = gson.fromJson<ArrayList<String>>(stringObject, object :TypeToken<ArrayList<String>>(){}.type)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With