我正在使用volley在android中进行网络调用。我的web服务是给我response对象那样如何从json对象获取代码
{
"Code": 200,
"Message": "Record Found",
"Result": {
"deviceid": 10,
"udid": "359447060356151",
"businessid": 1,
"usertype": "Merchant"
}
}
现在我想读取该对象的代码和消息。但没有这样做。我正在使用此代码获取此数据。
JSONObject jsonObj = new JSONObject(response);
JSONObject userDetails = jsonObj.getJSONObject("Result");
LoginResponse entryObj = new LoginResponse();
entryObj.businessid = userDetails.getInt("businessid");
lr.businessid = entryObj.businessid;
Utilities.businessId = lr.businessid;
帮我读这个对象的代码。我没有得到确切的解决方案。
您是否调试过您是否获得价值? –
检查下面的答案。 –
我有upvoted的答案,这是正确的,你的代码是int,所以你必须使用getInt() – Mohit