Read A Particular Name Value Pair From Json With Multiple Objects Using Retrofit In Android
{ 'name':'xyz', 'result':'success' } I need to compare the result and if it is success replace with a new Activity. I am using retrofit call back methods. How to i read only a p
Solution 1:
You can use below code for read a particular name value pair from JSON.
JSONArray jsonarray = newJSONArray(json_string);
for (int i = 0; i < jsonarray.length(); i++) {
JSONObject jsonobject = jsonarray.getJSONObject(i);
String name = jsonobject.getString("name");
String result = jsonobject.getString("result");
}
Solution 2:
hello friends you can do it with this way for jsonobject data . x="your data".......... in this case this is best
JSONObject jobj=new JSONObject(x);
String name=jobj.getString("name");
String result=jobj.getString("result");
if you want to know some more about json object or JsonArray this is simple use this web site for know object and Array of Json
Post a Comment for "Read A Particular Name Value Pair From Json With Multiple Objects Using Retrofit In Android"