Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Unknown how to get the JSON path for an unnamed json array?

right now I have this JSON.

{
 "kind": "youtube#channelListResponse",
 "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/SGu14Buo6xWrEuoFga6kBy4vZBs\"",
 "pageInfo": {
  "totalResults": 1,
  "resultsPerPage": 1
 },
 "items": [
  {
   "kind": "youtube#channel",
   "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/Gtb_6T1CwMLCWtseKBhUt_R95fg\"",
   "id": "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
   "statistics": {
    "viewCount": "19368312391",
    "commentCount": "0",
    "subscriberCount": "73782288",
    "hiddenSubscriberCount": false,
    "videoCount": "3672"
   }
  }
 ]
}

on line 9 you see an unnamed array but I have no Idea how to get the path for that.

I used this website to get what I used below: http://jsonpathfinder.com/

While I tried many paths to get the subscriberCount. The one below is one of the ones I used and cannot figure out how to get the value of it.

info.items[0].statistics.subscriberCount

2 comments

0

If you need any more information feel free to comment!

0

Arrays start at 1, not 0

1 answer

✓ Accepted answer

JavaScript array indices start at 0, therefore this website -- thinking you were trying to access the element in JavaScript -- gave you a zero-based array index.

However Lua array indices start at 1, so the index is wrong.

Use array index 1 and everything should work fine.

This discussion is preserved as it was. New answers, comments, and votes are closed.