Voglio analizzare il mio array Json in modo dinamico. e voglio ottenere una serie di KEY per ogni elemento sotto jsonarray. ho ottenuto questo attraverso iteratore. ma non ottenendo il sequestro come per l'output json formate.ottieni un array di KEY per ogni elemento sotto jsonarray
mia JSON formiato:
{
"result": "Success",
"AlertDetails": [
{
"ShipmentNumber": "SHP34",
"Customer": "BEST",
"DateCreated": "2012-08-29T04:59:18Z"
"CustomerName": "BEST"
},
{
"ShipmentNumber": "SHP22",
"Customer": "BEST",
"DateCreated": "2012-08-29T05:34:18Z"
"CustomerName": "Jelly"
}
]
}
Ecco il mio codice:
JSONArray array = jsonobject.getJSONArray("AlertDetails");
JSONObject keyarray = array.getJSONObject(0);
Iterator temp = keyarray.keys();
while (temp.hasNext()) {
String curentkey = (String) temp.next();
KEYS.add(curentkey);
}
Log.d("Parsing Json class", " ---- KEYS---- " + KEYS);
cosa sto ottenendo in uscita logcate:
---- KEYS---- [DateCreated,CustomerName, Customer, ShipmentNumber]
quello che voglio:
---- KEYS---- [ShipmentNumber, Customer, DateCreated,CustomerName]
è KEYS un arrayList? –
@LazyNinja no è solo un nome. –
@LazyNinja Sì, è un arraylist. puoi per favore aiutarmi a uscire da questo? Sarebbe fantastico se mi dai suggerimenti per questo problema. –