-4

this is my json response

{
  "status": true,
  "code": 200,
  "message": "Success",
  "data": {
    "id": "14"
  }
}

how to read this values

Phantômaxx
  • 37,352
  • 21
  • 80
  • 110
taru khan
  • 13
  • 4

2 Answers2

1

You can use the help of Google's GSON library built for exact your pupose.

YourPojoClass model = new Gson().fromJson(jsonResponse, YourPojoClass.class);

Convert your json to PojoModel by using jsonschema2pojo.org

Alex Chengalan
  • 7,891
  • 3
  • 40
  • 54
0

You can do it like this:

Create a JSONObject:

JSONObject jObject = new JSONObject(result);

To get a specific boolean

String aJsonString = jObject.getBoolean("status");

To get a specific String

String aJsonString = jObject.getString("message");

To get a specific Integer

int aJsonInteger = jObject.getInt("code");
solamente
  • 263
  • 2
  • 15