I'm trying to create the following results in a JSON file:
"numbers": [
{
"small": 2,
"large": 5,
"type": "single"
},
{
"small": 10,
"large": 50,
"type": "double"
}]
I can't seem to figure out how to use JSON Simple to make this happen (coding in Java). When I use:
JSONObject obj = new JSONObject();
obj.put("small", 2);
it doesn't add it to the array. When I create an array:
JSONArray nums = new JSONArray();
nums.add("small", 2)
it doesn't work because add() won't take two parameters.
Please help!
That means an array (
[ ]
) of object ({ }
).So: