I want to parse these kind of Json responses :
{
\"MyResponse\": {
\"count\": 3,
\"listTsm\": [{
\"id\": \"b90c6218-73c8-30bd-b532-5ccf435da7
public static void main(String[] args) throws JSONException {
String jsonString = "{" +
" \"MyResponse\": {" +
" \"count\": 3," +
" \"listTsm\": [{" +
" \"id\": \"b90c6218-73c8-30bd-b532-5ccf435da766\"," +
" \"simpleid\": 1," +
" \"name\": \"vignesh1\"" +
" }," +
" {" +
" \"id\": \"b90c6218-73c8-30bd-b532-5ccf435da766\"," +
" \"simpleid\": 2," +
" \"name\": \"vignesh2\"" +
" }," +
" {" +
" \"id\": \"b90c6218-73c8-30bd-b532-5ccf435da766\"," +
" \"simpleid\": 3," +
" \"name\": \"vignesh3\"" +
" }]" +
" }" +
"}";
JSONObject jsonObject = new JSONObject(jsonString);
JSONObject myResponse = jsonObject.getJSONObject("MyResponse");
JSONArray tsmresponse = (JSONArray) myResponse.get("listTsm");
ArrayList list = new ArrayList();
for(int i=0; i
Output:
[vignesh1, vignesh2, vignesh3]
Comment: I didn't add validation
[EDIT]
other way to load json String
JSONObject obj= new JSONObject();
JSONObject jsonObject = obj.fromObject(jsonString);
....