I am using Jackson and I want to replace a value of my json string but I am not sure how should I do it. I have a json string like:
"body": {
"name": "oldname",
"label": "1234"}
I would like to change the value of name to have my json like:
"body": {
"name": "newname",
"label": "1234"}
so I have:
JsonNode parser = objectMapper.readTree(reader);
JsonNode body = parser.path("body");
String newName = "newname";
with using
body.path("name").asText().replace("oldname","newname");
it does not work.
How I can do it?