sark9012
sark9012

Reputation: 5747

how to access to data from JSON object in Android?

My JSONObject:

JSONObject callback = {"message": "message here", "response": "response here"}

I want get the response here from json's respone string. I've tried the following:

JSONObject response = callback.getJSONObject("response");
String message = next.getString("response");

I get the errot like String and JSONObjet conversion problems.

Upvotes: 0

Views: 61

Answers (2)

GrIsHu
GrIsHu

Reputation: 23638

Try out as below:

JSONObject callback = {"message": "message here", "response": "response here"}

String response = callback.getString("response");
String message = callback.getString("message");

Upvotes: 1

Kirtan
Kirtan

Reputation: 1812

JSONObject callback = {"message": "message here", "response": "response here"}

you need to access response value like below code

String response = callback.getString("response");

Upvotes: 1

Related Questions