"ORDERDETAIL":[
{
"Description":"asdf",
"Quantity":"5",
"Unit Price":"77",
"No.":"1",
"Line No.":"100",
"Document Type":"1",
"Document No.":"109"
},
{
"Description":"torage",
"Quantity":"5",
"Unit Price":"7",
"No.":"19",
"Line No.":"10",
"Document Type":"1",
"Document No.":"10"
},
{
"Description":"IN",
"Quantity":"5",
"Unit Price":"7",
"No.":"1",
"Line No.":"1",
"Document Type":"1",
"Document No.":"9"
}
]
Code Part:
ArrayList<String> arlstKeyDetail = new ArrayList<String>();
ArrayList<String> arlstValDetail = new ArrayList<String>();
JSONArray jsonSubDataArry = new JSONArray();
JSONObject jsonSubObj = new JSONObject();
JSONObject jsonTemp1 = new JSONObject();
Iterator iterKey = jsonArrDisplayRecord.getJSONObject(1).keys();
while(iterKey.hasNext())
{
String key = (String)iterKey.next();
arlstKeyDetail.add(key);
arlstValDetail.add(jsonArrDisplayRecord.getJSONObject(1).getString(key));
}
for(int i=0 ; i < arlstKeyDetail.size() ; i++)
{
for(int j=0; j <itLength; j++){
jsonSubObj.put(arlstKeyDetail.get(j), arlstValDetail.get(j));
}
jsonSubDataArry.put(jsonSubObj);
jsonTemp1.put("ORDERDETAIL", jsonSubDataArry);
}
I want to create Json Object with Json Array like above format in android. i already tried lots of thing but didnt get as like above.