-4

this is my json response

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

how to read this values

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
taru khan
  • 13
  • 6

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
  • 8,211
  • 4
  • 42
  • 56
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
  • 266
  • 2
  • 15