How to Parse JSON Object:
first we get data from server afterthat we parse, in JSON start with Object or Array.
{ } = Object
[ ] = Array
so we check data is object or array.
String result= {"response":"100","data" : "Sucess"}
It is start with object so first object parse then string.
It is start with object so first object parse then string.
try {
JSONObject json = new JSONObject(result);
String response= json
.getString("response");
String data= json
.getString("data");
} catch (JSONException e) {
e.printStackTrace();
}
we get response = 100;
and data= Sucess
No comments :
Post a Comment