-7
[
  {

    "stDescription": "END N/A",
    "stCategory": "6",
    "sZone": "@",
    "sIncident": "0"
  },
  {

    "stDescription": "BEG N/A",
    "stCategory": "6",
    "sZone": "@",
    "sIncident": "0"
  },
  {

    "stDescription": "",
    "stCategory": "Null",
    "sZone": "4",
    "sIncident": "0"
  },
  {

    "stDescription": "",
    "stCategory": "Null",
    "sZone": "5",
    "sIncident": "0"
  }
]

There is no array name here, but I want to parse whole array (my JSON parser works fine if I'm using array name).

J. Steen
  • 15,470
  • 15
  • 56
  • 63
John
  • 3
  • 1
  • 4

1 Answers1

0

For parsing this type of JSON...

First store it in String..

and then do following process...

String str = "JSON STRING";
JSONArray jsonarray = new JSONArray(str);

for(int i=0; i<jsonarray.length(); i++){
    JSONObject obj = jsonarray.getJSONObject(i);

    String stDescription = obj.getString("stDescription");
    String stCategory= obj.getString("stCategory");
    //and other fields

    System.out.println(stDescription);
    System.out.println(stCategory);
}  

This may help you...

Pragnesh Ghoda シ
  • 8,318
  • 3
  • 25
  • 40