Home java JSON Parsing on Java, JSonarray, Nested Arrays, [[

JSON Parsing on Java, JSonarray, Nested Arrays, [[

Author

Date

Category

Hello. Fragment JSON strings.

{"Creators":
 [
   {
    "ID": "30322",
    "ProfessionKey": "Director"
   }
 ],
 [
   {
    "ID": "1682023",
    "ProfessionKey": "Actor"
   },
   {
    "ID": "1876",
    "ProfessionKey": "Actor"
   }
 ],
 [
   {
    "ID": "31095",
    "PROFESSIONKEY": "PRODUCER"
   },
   {
    "ID": "1093329",
    "PROFESSIONKEY": "PRODUCER"
   }
 ]]}

or briefly {"Creators": [[{"ID": "30322", "ProfessionKey": "Director"}], [....]]}
The complexity lies in the next square brackets. I believe that this is a two-dimensional array. I tried different options, c jsonarray, jsonobject. The code below put in GetJsonarray (NULL) “. Please help.

jsonarray creatorscontent = parentobject.getjsonarray ("Creators");
JSonarray FinalArray = CreatorsContent.getjsonobject (0) .Getjsonarray (NULL);
ProfessionKey = CreatorsContent.getString ("ProfessionKey");

Answer 1, Authority 100%

I don’t know which library you use, but in org.json This is done:

jsonarray jsonarray = new jsonobject (jsonstr) .Getjsonarray ("Creators"). GetJsonarray (0);
System.out.PrintLN (jsonarray.get (0) .tostring ());

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions