[Solved] How to read Json data in android [closed]


This is the simplest way to parse your JSON String. I would suggest your to read JSON documents.

But, here is a sample code.

try {
        String jsonString = new String("[{\"id\": \"1\",\"name\": \"abc\",\"type\": \"consumer\"}]");
        JSONArray jsonArray = new JSONArray(jsonString);
        for(int index = 0;index < jsonArray.length(); index++) {
            JSONObject jsonObject = jsonArray.getJSONObject(index);
            String id = jsonObject.getString("id");
            String name = jsonObject.getString("name");
            String type = jsonObject.getString("type");
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

You can also parse using GSON https://code.google.com/p/google-gson/

solved How to read Json data in android [closed]