I have the following JSON structure:
{
"PARAMORDER": [{
"TAB1": [{
"1": "Picture ID Source"
}, {
"2": "Place of Issuance"
}],
"TAB2": [{
"1": "Picture ID Source"
}, {
"2": "Place of Issuance"
}]
}]
}
I am trying to create a JSON Array using java code which looks like the above format when it is parsed and retrieved. I am using org.json.simple API for this. However I am unable to create an array of array in JSON using java code. Can someone please share me a sample code which can construct the JSON in the above format.
Below is the sample code I tried which creates a json array:
JSONArray jsonArray = new JSONArray();
JSONObject firstJson = new JSONObject();
JSONObject secondJson = new JSONObject();
firstJson.put("1", "Picture ID Source");
secondJson.put("1", "Picture ID Source");
jsonArray.add(firstJson);
jsonArray.add(secondJson);
System.out.println(jsonArray.toString);
This gives me the following JSON:
[{
"1": "Picture ID Source"
}, {
"1": "Picturesecond ID Source"
}]
I am unable to create a JSONArray of JSONArray. Can someone please help me with that? Thanks in Advance.