Create Json object from strings in java
String string;
JSONObject obj = new JSONObject();
json.put("name", "Ram");
JSONArray myarr = new JSONArray();
JSONObject json = new JSONObject();
json.put("address", "test");
json.put("id", 3);
json.put("course", "MCA");
array.put(json);
json.put("0", arr);
string= json.toString();
Output:
// string// {"0":[{"id":3,"address":"test","course":"MCA"}],"name":"Ram"}
Comments
Post a Comment