I'm new to JSON. I'm trying to create a JSON string in Java (org.json.JSONObject(json.jar)) which resembles like (basically a set of name-value pairs)
[{
"name": "cases",
"value": 23
}, {
"name": "revenue",
"value": 34
}, {
"name": "1D5",
"value": 56
}, {
"name": "diag",
"value": 14
}]
Can anyone help me on how to create this in Java? I want the name and value to be in each so that i can iterate over the collection and then get individual values.
See Question&Answers more detail:os