试试这个动态的JSON解析器
private void parseJson(JSonObject data) { if (data != null) { Iterator<String> it = data.keys(); while (it.hasNext()) { String key = it.next(); try { if (data.get(key) instanceof JSONArray) { JSonArray arry = data.getJSonArray(key); int size = arry.length(); for (int i = 0; i < size; i++) { parseJson(arry.getJSonObject(i)); } } else if (data.get(key) instanceof JSONObject) { parseJson(data.getJSonObject(key)); } else { System.out.println(key + ":" + data.getString(key)); } } catch (Throwable e) { try { System.out.println(key + ":" + data.getString(key)); } catch (Exception ee) { } e.printStackTrace(); } } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)