I am getting an json array from rest webservice in response which is like
[{
"mutualFund":{"fundCode":"XYZ","fundName": "Funds - Global Income
Fund (G)-SGD","isin":"LU0882574725","sedol":"1234"}},
{"brokers":{"fundID":"abcd","fundName":"Funds - Focus
Fund A-USD","isin":"LU0197229882","sedol":"6543"}
}]
I am trying to iterate over all mutualFund arrays attributes to fetch their value. I have tried this code snippet but its returning error --"mutualFund do not exist". In my json file some objects are of mutualfund type and some are of other type with different attributes so I had to iterate and differentiate between both of them . So I cant use getJSONObject(i).
JSONArray jsonArray=new JSONArray(response.getBody());
for(int i=0;i<jsonArray.length();i++){
JSONObject jsonObject=jsonArray.getJSONObject("mutualFund");
}