// JSON object to hold the information, which is sent to the server
JSONObject jsonObjSend = new JSONObject();
jsonObjSend.put(\"action\", \"myAction\");
jsonObjSend
After seeing the example I understood that you are trying to do something similar as asked in Java JsonObject array value to key
jsonObjSend.put("elementi", new JSONArray(new Object[] { "value1", "value2", "value3"} ));
To simplify:
JSONArray arr = new JSONArray();
arr.put("value1");
arr.put("value2");
//...
jsonObjSend.put("elementi", arr);
JSONObject jsonBody = new JSONObject();
jsonBody.put("action", "myAction"); //action is your string
jsonBody.put("type", "elementi");
JSONArray arr = new JSONArray();
JSONObject elementi= new JSONObject();
itemList.put("id", id);
itemList.put("name", name);
arr.put(elementi);
jsonBody.put("elementi", arr);