-2
我有这样的JSON:如何检查JSON是否嵌套在Java中?
{
"id": 2643743,
"dt": 1485789600,
"clouds": {
"all": 90
}
}
在这个JSON,我怎么可以检查,有一个嵌套的JSON的关键?例如,我如何检查云是否嵌套了JSON?
JSONObject json = readJsonFromUrl("http://samples.openweathermap.org/data/2.5/weather?q=London,uk&APPID=916c290adb437e1cc53eab01798225ed");
Iterator keys = json.keys();
Iterator inskeys = json.keys();
String keyStr = null;
while(keys.hasNext()) {
keyStr = (String) keys.next();
Object keyvalue = json.get(keyStr);
Object keyType = keyvalue.getClass().getSimpleName();
...
帖子你尝试过什么。至少说出你正在使用的几十个JSON解析API中的哪一个。 –
那么,为什么不检查价值的类型? – Henry