Let take your response and analyse it, for make it more understandable I will place some index values, and consider response comment
//index0 {
"id": "11",
"snippet": {
"topLevelComment": {
"snippet": {
"textDisplay": "SOME COMMENT 2 "
}
}
}
},
//index0 {
"id": "22",
"snippet": {
"topLevelComment": {
"snippet": {
"textDisplay": "SOME COMMENT 2"
}
}
}
},
You will get your response in above format, so to get details of each snippet navigate through indexes
comment[0]
will extract the first element of the response.
comment[0].id
will extract the first element id of the response.
comment[0].snippet
will extract the first snippet of the response.
comment[0].snippet.topLevelComment
will extract the first snippet's topLevelComment of the response.
So on like this we can read response and get the data we need in your case you need to get textDisplay so you can use following code,
comments[0].snippet.topLevelComment.snippet.textDisplay
To go through all indexes you can use for-each as following
for (x in comments) {
comments[x].snippet.topLevelComment.snippet.textDisplay
}