我需要分析一些JSON对象,whihc看起来是这样的:JSON对象解析
{"searchdata":{},"userdata":{"currency":"69","notificationCount":7}}
我用下面的代码来实现这一目标:
JSONObject rootObj = new JSONObject(getResponse);
JSONObject jSearchData = rootObj.getJSONObject("searchdata");
JSONObject userData = jSearchData.getJSONObject("userdata");
String currency = userData.getString("currency");
我不能打印currency
对象来自上面的代码。我不断收到异常:
Exception: org.json.JSONException: No value for userdata
我不知道我在做什么错。
任何形式的帮助将不胜感激。
痛苦少):https://sites.google .com/site/gson/gson-user-guide#TOC-Using-Gson – MemLeak 2013-04-24 08:30:21