// Create a new instance of a JSONArray
JSONArray array = new JSONArray();
// With put() you can add a value to the array.
array.put("ASDF");
array.put("QWERTY");
// Create a new instance of a JSONObject
JSONObject obj = new JSONObject();
try {
// Add the JSONArray to the JSONObject
obj.put("the_array", array);
} catch (JSONException e) {
e.printStackTrace();
}
String json = obj.toString();
The resulting JSON string looks like this:
{
"the_array":[
"ASDF",
"QWERTY"
]
}