-3
returnLogin([{
    "id": 0,
    "first_name": "abc",
    "last_name": "xyz",
    "msg": "Invalid User or Location ID or Password.",
    "location_id": "",
}])

How to get data from above Json string? here json start with witn string not any bracket thats why i try to. getting data

Manish
  • 67
  • 8

1 Answers1

0

you can parse like below,

String data = "";// here your json data which will parse
        try {
            JSONArray jsonArray = new JSONArray(data);
            JSONObject jsonObject=jsonArray.getJSONObject(0);
            int id=jsonObject.getInt("id");
            String first_name=jsonObject.getString("first_name");
            String last_name=jsonObject.getString("last_name");
            String msg=jsonObject.getString("msg");
            String location_id=jsonObject.getString("location_id");
        } catch (JSONException e) {
            e.printStackTrace();
        }

But before parse correct your data.

Dhaval Solanki
  • 4,589
  • 1
  • 23
  • 39