2 回答

TA貢獻1878條經驗 獲得超4個贊
您可以使用我使用過的任何 json 解析器來提取數據org.json
以下代碼嘗試從您的 json 數據中查找 OFFICER。
JSONObject obj = new JSONObject(jsonString);
JSONArray objArray = obj.optJSONArray("root");
for (Object jo : objArray) {
JSONObject arrayElement = new JSONObject(jo.toString());
JSONArray childrenArray = arrayElement.getJSONArray("children");
for (Object child : childrenArray) {
JSONObject childJo = new JSONObject(child.toString());
if (Integer.parseInt(childJo.get("refDataId").toString()) == 99) {
if (childJo.get("otherValue").toString().equals("Officer")) {
System.out.println("Success Officer Found !");
}
}
}
}
添加回答
舉報