use of org.hisp.dhis.commons.jackson.jsonpatch.JsonPatch in project dhis2-core by dhis2.
the class RemoveOperationTest method testRemovePropertyFromMap.
@Test
void testRemovePropertyFromMap() throws JsonProcessingException, JsonPatchException {
JsonPatch patch = jsonMapper.readValue("[" + "{\"op\": \"remove\", \"path\": \"/props/id\"}" + "]", JsonPatch.class);
assertNotNull(patch);
Map<String, String> map = new HashMap<>();
map.put("id", "123");
ObjectNode root = jsonMapper.createObjectNode();
root.set("props", jsonMapper.valueToTree(map));
assertTrue(root.has("props"));
assertTrue(root.get("props").has("id"));
root = (ObjectNode) patch.apply(root);
assertTrue(root.has("props"));
assertFalse(root.get("props").has("id"));
}
Aggregations