Hi, I'm trying to update an object inside an
{
...
arrayKey: [{
key1: value1,
key2: value2
}
]
...
}
The objective is to change the value of key1. The only way I could find to do it, is to replace the entire object with the following:
String objectValue = new ObjectMapper().valueToTree(fieldValue.get(0)).toString();
XContentParser parser = JsonXContent.jsonXContent
.createParser(NamedXContentRegistry.EMPTY,objectValue);
contentBuilder.startArray(fieldName);
contentBuilder.copyCurrentStructure(parser);
contentBuilder.endArray();
Is there a better way? Thanks!