请支持 JsonRequest
Support for JsonRequest please
我有以下 json:
{
"code": "1",
"status": "OK",
"users": [
{
"id": "5",
"yazi": "launcher",
"gun": "2015-08-04"
},
{
"id": "6",
"yazi": "piano",
"gun": "2015-02-02"
},
{
"id": "9",
"yazi": "text text",
"gun": "2015-08-05"
},
{
"id": "14",
"yazi": null
"gun": "2015-02-02"
}
] }
我想在代码为“1”且状态为 "OK" 时查看用户参数。
我应该使用什么?
使用这个
JSONObject obj=new JSONObject();
String status=obj.getString("status");
String code=obj.getString("code");
if(code.equalsIgnoreCase("1") && status.equalsIgnoreCase("OK"))
{
//Parse your users array
}
这是解析 JSONObject
:
的代码
JSONObject object = new JSONObject(jsonString);
String code = object.optString("code");
String status = object.optString("status");
if (code.equals("1") && status.equals("OK")) {
JSONArray users = object.getJSONArray("users");
// do your code
}
我有以下 json:
{
"code": "1",
"status": "OK",
"users": [
{
"id": "5",
"yazi": "launcher",
"gun": "2015-08-04"
},
{
"id": "6",
"yazi": "piano",
"gun": "2015-02-02"
},
{
"id": "9",
"yazi": "text text",
"gun": "2015-08-05"
},
{
"id": "14",
"yazi": null
"gun": "2015-02-02"
}
] }
我想在代码为“1”且状态为 "OK" 时查看用户参数。 我应该使用什么?
使用这个
JSONObject obj=new JSONObject();
String status=obj.getString("status");
String code=obj.getString("code");
if(code.equalsIgnoreCase("1") && status.equalsIgnoreCase("OK"))
{
//Parse your users array
}
这是解析 JSONObject
:
JSONObject object = new JSONObject(jsonString);
String code = object.optString("code");
String status = object.optString("status");
if (code.equals("1") && status.equals("OK")) {
JSONArray users = object.getJSONArray("users");
// do your code
}