我试图将嵌套数组项中的对象编辑 "field2": "desc 2"
到"field2": "xxxx"
下面的 json 中:
{
"item1": 123,
"item2": "desc 1",
"item3": [
{
"field1": "desc 1",
"field2": "desc 2"
}
]
}
我试过这个解决方案
root = objectMapper.readTree(new File(filePath))
((ObjectNode) root).put("field2", "desc xxxx");
输出是:
{
"item1": 123,
"item2": "desc 1",
"item3": [
{
"field1": "desc 1",
"field2": "desc 2"
}
],
"field2": "desc xxxx"
}