相关疑难解决方法(0)

如何在Java中修改JsonNode?

我需要在Java中更改JSON属性的值,我可以正确获取值但是我无法修改JSON.

这是下面的代码

  JsonNode blablas = mapper.readTree(parser).get("blablas");
    for (JsonNode jsonNode : blablas) {
        String elementId = jsonNode.get("element").asText();
        String value = jsonNode.get("value").asText();
        if (StringUtils.equalsIgnoreCase(elementId, "blabla")) {
            if(value != null && value.equals("YES")){
                 // I need to change the node to NO then save it into the JSON
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

做这个的最好方式是什么?

java json jackson

91
推荐指数
4
解决办法
9万
查看次数

标签 统计

jackson ×1

java ×1

json ×1