I have this ugly JSON string and I need to get the totalStars
which in this case is 500. I have tried quite some solutions but none seem to work.
This is the JSON
:
{
"code": 200,
"message": "success",
"data": [
[
{
"totalPosts": 42
}
],
[
{
"totalStars": 500
}
],
[
{
"followingCount": 1
}
],
[
{
"followerCount": 1
}
]
]
}
And at the moment I'm trying to get the data with this:
JSONObject jsonResult = new JSONObject(result);
JSONArray data = jsonResult.getJSONArray("data");
if(data != null) {
String[] names = new String[data.length()];
for(int i = 0 ; i < data.length() ; i++) {
names[i] = data.getString(i);
}
System.out.println(names);
}
The JSONArray
data contains the correct data, but I cant seem to get the other data out of it.