Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
uhTeddy 101
6 years ago
Edited 6 years ago

right now I have this JSON.

01{
02 "kind": "youtube#channelListResponse",
03 "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/SGu14Buo6xWrEuoFga6kBy4vZBs\"",
04 "pageInfo": {
05  "totalResults": 1,
06  "resultsPerPage": 1
07 },
08 "items": [
09  {
10   "kind": "youtube#channel",
11   "etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/Gtb_6T1CwMLCWtseKBhUt_R95fg\"",
12   "id": "UC-lHJZR3Gqxm24_Vd_AJ5Yw",
13   "statistics": {
14    "viewCount": "19368312391",
15    "commentCount": "0",
View all 22 lines...

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.

1info.items[0].statistics.subscriberCount
0
If you need any more information feel free to comment! uhTeddy 101 — 6y
0
Arrays start at 1, not 0 hiimgoodpack 2009 — 6y

1 answer

Log in to vote
1
Answered by
Link150 1355 Badge of Merit Moderation Voter
6 years ago
Edited 6 years ago

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.

Ad

Answer this question