-3

I know how to parse json but I can not solve integer json field in this json. Because this json contain integer field(23254,23998).

Here my JSON

 {  
       "status":"OK",
       "alarms":{  
          "23254":[  
             {  
                "speed_limit":250,
                "acc_limit":null,
                "dcc_limit":null,
                "idle_limit":null
             }
          ],
          "23998":[  
             {  
                "speed_limit":120,
                "acc_limit":null,
                "dcc_limit":null,
                "idle_limit":null
             }
          ]
       }
    }
sasikumar
  • 12,540
  • 3
  • 28
  • 48

2 Answers2

0

Parse the Json object like this way

JSONObject obj= new JSONObject(content);
Iterator iterator = obj.keys();
while(iterator.hasNext()){
String key = (String)iterator.next();
JSONObject object1 = obj.getJSONObject(key);

//  get id from  object1
    String _pubKey = object1.optString("id");
}
Shree Krishna
  • 8,474
  • 6
  • 40
  • 68
0
   try{
        JSONObject j=new JSONObject("here put your response string");
         JSONObject j1= j.getJSONObject("alarms");
        ArrayList<String> arr=new ArrayList<String>();
        Iterator iter = j1.keys();
        while(iter.hasNext()){
            String key = (String)iter.next();
            arr.add(j1.getJSONArray(key).toString());
            System.out.println("json"+j1.getJSONArray(key).toString());
        }

    }catch (JSONException e){

e.printStackTrace(); }

Lakhan patidar
  • 109
  • 1
  • 3