I have the following JSONArray:
[
{
"Lng":17.908817,
"name":"S1",
"id":1,
"sensor:":[
"Temperature",
"Wind"
],
"Lat":47.089492
},
{
"Lng":17.908458,
"name":"S2",
"id":2,
"sensor:":[
"Temperature",
"Wind",
"Humidity"
],
"Lat":47.089246
},
{
"Lng":17.908222,
"name":"S3",
"id":3,
"sensor:":[
"Wind"
],
"Lat":47.089662
}
]
I can split it to JSONObject but if I try to split the Object it returns null.
My code:
Object object = JSONValue.parse(result);
JSONArray array = (JSONArray)object;
for(int i = 0 ; i < array.size(); i++){
System.out.println(array.get(i));
JSONObject jsonObject = (JSONObject)array.get(i);
for(int j = 0 ; j < jsonObject.size(); j++){
System.out.println(jsonObject.get(j));
}
}
Result:
{"Lng":17.908817,"name":"S1","sensor:":["Temperature","Wind"],"id":1,"Lat":47.089492}
null
null
null
null
null
{"Lng":17.908458,"name":"S2","sensor:":["Temperature","Wind","Humidity"],"id":2,"Lat":47.089246}
null
null
null
null
null
{"Lng":17.908222,"name":"S3","sensor:":["Wind"],"id":3,"Lat":47.089662}
null
null
null
null
null