I've a JSON like this
{
"result":
{
"issue_date": "xx-yy-zzzz",
"father/husband": "TEST",
"name": "ABC ",
"blood_group": "",
"dob": "xx-yy-zzzz",
"validity": {
"non-transport": "xx-yy-zzzz to xx-yy-zzzz",
"transport": "xx-yy-zzzz to xx-yy-zzzz"
},
"cov_details": {
"MCWG": "NA",
"3WTR": "NA",
"PSV BUS": "NA",
"LMV": "NA",
"INVCRG": "NA"
},
"address": "ABC"
}
}
JSONObject dlData = new JSONObject();
JSONObject dlObj = new JSONObject();
JSONObject dlcov = new JSONObject();
JSONObject dlCovs = new JSONObject();
dlCov = jsonObject.getJSONObject("result").getJSONObject("cov_details");
to access the data of cov_details, i'm using this code block to store the details present within cov_details Object
dlcov = jsonObject.getJSONObject("result").getJSONObject("cov_details");
Iterator<String> x = dlcov.keys();
while (x.hasNext()){
String key1 = x.next();
String value1 = dlcov.optString(key1);
dlCovs.put("covabbrv",key1);
dlCovs.put("dcIssuedt",value1);
dlCovs.put("vecatg",key1);
}
dlData.put("dlCovs", dlCovs);
i am trying to store every values in dlCovs but it stores only last values in the object, is their anyway using which i can store all the value in dlCovs objet with it's Key value and iterate over it.Any help will be highly appreciable, thanks well in advance. enter code here
dlCovsdefined?