I need to parse this information-
[
{
"artist": "12",
"image": "23"
},
{
"video_id": "12",
"video_title": "23"
},
{
"video_id": "12",
"video_title": "23"
},
{
"video_id": "12",
"video_title": "23"
},
{
"video_id": "12",
"video_title": "23"
},
{
"video_id": "12",
"video_title": "23"
}]
As you can see the first field is different, how to parse below information differently and the first field differently in Kotlin.
I am parsing 1st part as-
response ->
for (i in 0..(response.length() -1)){
/**
FIRST SONG
**/
val song = response.get(0).toString()
val listOfSongs = response.toString()
val parser = Parser()
val stringBuilder = StringBuilder(song)
val json: JsonObject = parser.parse(stringBuilder) as JsonObject
val firstArtist = json.string("artist")
val firstImage = json.string("image")
val intent = Intent(activity,ResultPage::class.java)
intent.putExtra("firstArtist",firstArtist)
intent.putExtra("firstImage",firstImage)
startActivity(intent)
/**
FIRST SONG
**/
}
}
and am also using KLAXON library here.