This is very simple one but struggeling. help me out of this.
I am having a json data { \"abc\":\"test\",\"bed\":\"cot\",\"help\":\"me\"}
I want to convert a
Directly put JsonObject i.e. obj into jsonArray
jsonArray.put(obj);
//result is [{ "abc":"test","bed":"cot","help":"me"}]
Final code
JSONObject obj= new JSONObject(str);
JSONArray jsonArray = new JSONArray();
//simply put obj into jsonArray
jsonArray.put(obj);
//result is [{ "abc":"test","bed":"cot","help":"me"}]
It works for me.
JSONObject obj = new JSONObject(result.toString()); JSONArray arr = obj.getJSONArray("value");