Sagar Zala
Sagar Zala

Reputation: 5134

How to convert buffered-reader string to JSON in android?

I get json response in Buffered Reader. Now How to convert buffered-reader string to JSON?

I get the String like

[
  {
    "email": "[email protected]",
    "password": "test@123!",
    "role": "monitor",
    "code": "0"
  }
]

Upvotes: 1

Views: 3063

Answers (2)

Paresh Mayani
Paresh Mayani

Reputation: 128428

You can create JSONArray with the response string by using:

JSONArray arrayJSON = new JSONArray(responseString);

And use getJSONObject() to get JSONObject and use getString() to get string value from particular JSONObject.

Upvotes: 3

Digvesh Patel
Digvesh Patel

Reputation: 6533

JSONArray aardata = new JSONArray(your buffered reader String):

And For Parse

  JSONObject obj = arrdata.getJsonObject(0);

      String email = obj.getString('email');

Upvotes: 3

Related Questions