阅读JSON特定名称值对Android中使用改装多个对象 [英] Read a particular name value pair from JSON with multiple objects using Retrofit in Android
本文介绍了阅读JSON特定名称值对Android中使用改装多个对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
{
"name":"xyz",
"result":"success"
}
我需要比较的结果,如果它是成功的一个新的活动
更换。我使用改装回调方法。如何我只读一个特定的名称对以及如何继续如果我有多个对象说 JSON阵列
。
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 particular name pair and how to proceed if i had a multiple objects say JSON Array
.
推荐答案
您可以使用下面code为阅读JSON一个特定的名称值对。
You can use below code for read a particular name value pair from JSON.
JSONArray jsonarray = new JSONArray(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");
}
这篇关于阅读JSON特定名称值对Android中使用改装多个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文