inburst inburst - 3 months ago 14
Java Question

How to load a Json property that has no identifier?

I have a Json file that loads like this

[1,[1,[13278025],[[13278025,"88b926bfb5a68cbefa030926aac32e93",{"uid":"13278025","ujob":"2","sex":"1","uname":"User","ulv":"66","zhanli":"41992","vip":"0","step":"5","senior":"0"}]]]]


I really need to load the 13278025,"88b926bfb5a68cbefa030926aac32e93" up as variables. How would I go about doing this. I have worked on this for two days.

here is what a bigger sample looks like

[1,[1,[9267453,13273995,15879381,30177445,33192786,44165729,47469093],[[9267453,"e853147bc8f7496350a7a6c0d4e9c253",{"uid":"9267453","ujob":"2","sex":"1","uname":"Inburst","ulv":"3","zhanli":"223","vip":"0","step":"5","senior":"0"}],[13273995,"243402361f57a9151b0f852421b1942d",{"uid":"13273995","ujob":"3","sex":"1","uname":"Inburst","ulv":"150","zhanli":"208551237","vip":"10","step":"5","senior":"8"}],[15879381,"7098446d2edaad06695a63deab55ace0",{"uid":"15879381","ujob":"2","sex":"1","uname":"Inburst","ulv":"75","zhanli":"143894","vip":"4","step":"5","senior":"0"}],[30177445,"b8c15b5d4d8c38a513959514c8edb47e",{"uid":"30177445","ujob":"2","sex":"1","uname":"Inburst","ulv":"11","zhanli":"1363","vip":"0","step":"5","senior":"0"}],[33192786,"6fbd79925e78f90bb5793610ec1ea034",{"uid":"33192786","ujob":"2","sex":"1","uname":"Inburst","ulv":"19","zhanli":"2403","vip":"1","step":"5","senior":"0"}],[44165729,"848725f06b03e611331f2d1566a7303e",{"uid":"44165729","ujob":"3","sex":"1","uname":"Inburst","ulv":"11","zhanli":"447","vip":"0","step":"5","senior":"0"}],[47469093,"b5ee83361b3de89cdd369ce926cd3c5d",{"uid":"47469093","ujob":"2","sex":"1","uname":"Inburst","ulv":"9","zhanli":"662","vip":"0","step":"5","senior":"0"}]]]]


I am just not sure how to load this properties without identifiers.

Answer

They're not object properties, they're array elements. You access them by their index.

In Javascript:

var data = [1,[1,[13278025],[[13278025,"88b926bfb5a68cbefa030926aac32e93",{"uid":"13278025","ujob":"2","sex":"1","uname":"User","ulv":"66","zhanli":"41992","vip":"0","step":"5","senior":"0"}]]]];

console.log(data[1][2][0][0]); // 13278025
console.log(data[1][2][0][1]); // 88b926bfb5a68cbefa030926aac32e93

Comments