在Java中遍历json树结构

public void listest(@RequestBody  String strjson) {
    List ds =new ArrayList();
    JSONObject json = JSONObject.parseObject(strjson);
    for (Map.Entry, Object> firstEntry : json.entrySet()) {
        String firstValue=firstEntry.getValue().toString();
        if(firstValue.isEmpty()){
            continue;
        }
        int i = jsonParseServices.testIsObject(firstValue);
        if (i==1){
            System.out.println("+++++++++++++++++++++++++++++"+firstEntry.getKey()+"+++++++++++++++++++++++++++++++++++++");
            listest(firstValue);
        }
        else {
            System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>"+firstEntry.getKey().toString()+"::::"+firstValue+"<<<<<<<<<<<<<<<<<<<<<<<<");
        }
    }
}

你可能感兴趣的:(Java)