This is one of my json response.I need to get the value of href.I don't know the number of times the items array is repeating.Is there any way to parse these type of json arrays.
{"batch_header":
{"payout_batch_id":"123"},
"items":[
{"transaction_status":"PENDING",
"payout_batch_id":"56",
"links":[
{"href":"link"}
]}
],
"items":[
{"transaction_status":"PENDING",
"payout_batch_id":"78",
"links":[
{"href":"link"}
]
}
]
}
This is the code I tried.The code only work 1 for first loop and it break.
JSONObject obj = new JSONObject(response);
JSONArray dataOuter = obj.getJSONArray("items");
for (int i = 0; i < dataOuter.length() ; i++ ) {
JSONObject jObject1 = dataOuter.getJSONObject(i);
logger.info(" Items "+jObject1);
JSONArray dataInner = jObject1.getJSONArray("links");
for (int j = 0; j < dataInner.length() ; j++ ) {
JSONObject jItem = dataInner.getJSONObject(i);
responseURL = jItem.getString("href");
}
}