[英]Parsing JSON data in android
你好我试图从android中的下面的JSON获得“百分比”值,但无法正确解析它。
{
"Percent": 100,
"ErrorCode": null,
"ErrorNiceMessage": "",
"Warnings": [],
"Info": null,
"FormErrors": [],
"State": true,
}
我的代码如下,但我的空白值。 你能给些建议么。
JSONObject reader = new JSONObject(message);
JSONArray arr = reader.getJSONArray("Percent");
i = arr.getString(0);
使用此代码:
JSONObject reader = new JSONObject(message);
i = reader.getInt("Percent");
百分比不是JSON数组,它是一个引用整数值的键。
试试这种方式:
JSONObject reader = new JSONObject(message);
int percentValue = reader.getInt("Percent");
使用此代码
JSONObject reader = new JSONObject(message);
i = reader.optInt("Percent",0);// opt int will help you if Percent value is null then you will get default value as 0;
解析来自gateway.pusulacc.com.tr/api/developer/dashboard的数据
使用此代码
JSONObject data = new JSONObject(jsonData);
JSONObject resultObj= data.getJsonObject("Result");
double doubleValue=resultObj.getDouble("ServisServiyesi");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.