I have a json Object is like this:
{
Yg7R_: {
fld_invoice: \"Yg7R_\"
fld_order_id: \"5\"
fld_orders: {
4: {
f
Try this dynamic json parser
private void parseJson(JSONObject data) {
if (data != null) {
Iterator it = data.keys();
while (it.hasNext()) {
String key = it.next();
try {
if (data.get(key) instanceof JSONArray) {
JSONArray arry = data.getJSONArray(key);
int size = arry.length();
for (int i = 0; i < size; i++) {
parseJson(arry.getJSONObject(i));
}
} else if (data.get(key) instanceof JSONObject) {
parseJson(data.getJSONObject(key));
} else {
System.out.println(key + ":" + data.getString(key));
}
} catch (Throwable e) {
try {
System.out.println(key + ":" + data.getString(key));
} catch (Exception ee) {
}
e.printStackTrace();
}
}
}
}