public void listest(@RequestBody String strjson) { List<String> ds =new ArrayList<String>(); JSONObject json = JSONObject.parseObject(strjson); for (Map.Entry<String, 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中遍历json树结构
最新推荐文章于 2026-05-08 13:42:46 发布
本文介绍了一种使用Java实现的递归方法来解析JSON字符串的方法。该方法接收一个JSON字符串作为输入,通过递归调用自身来处理嵌套的对象。对于每一个层级的JSON对象,方法会检查其值是否为另一个对象,并根据检查结果决定是否继续递归调用。

1646

被折叠的 条评论
为什么被折叠?



