Slide 12
Slide 12 text
// JSON Patch is a web standard format for describing changes in a JSON document.
// The JSON Patch media type is application/json-patch+json.
[ { "op": "replace", "path": "/0/aString", "value": "Patched JSON-P." } ]
JsonArray jsonArray = Json.createArrayBuilder()
.add(Json.createObjectBuilder()
.add("aString", "Hello Json-P.")
.add("aInteger", 42)
.add("aBoolean", false)
.add("aNullValue", JsonValue.NULL))
.build();
JsonPatch jsonPatch = Json.createPatchBuilder(jsonPatchArray).build();
jsonPatch.apply(jsonArray)
Add: add a value into an object or array.
Remove: remove a value from an object or array.
Replace: replaces a value. Logically identical to
using remove and then add.
Copy: copy a value from one path to another by
adding the value at a specified to another location.
Move: moves a value from one place to another
by removing from one location and adding to
another.
Test: tests for equality at a certain path for a
certain value.