I\'m new to java so this is a bit confusing
I want to get json formatted string
The result I want is
{ \"user\": [ \"name\", \"lamis\" ] }
Another way of doing it is to use a JSONArray for presenting a list
JSONArray arr = new JSONArray(); arr.put("name"); arr.put("lamis"); JSONObject json = new JSONObject(); json.put("user", arr); System.out.println(json); //{ "user": [ "name", "lamis" ] }