public class JsonPatchBuilder extends Object
The following illustrates the approach.
JsonPatchBuilder builder = new JsonPatchBuilder();
JsonArray patch = builder.add("/John/phones/office", "1234-567")
.remove("/Amy/age")
.build();
The result is equivalent to the following JSON Patch.
[
{"op" = "add", "path" = "/John/phones/office", "value" = "1234-567"},
{"op" = "remove", "path" = "/Amy/age"}
] | Constructor and Description |
|---|
JsonPatchBuilder()
Creates JsonPatchBuilder with empty JSON Patch
|
JsonPatchBuilder(JsonArray patch)
Creates a JsonPatchBuilder, starting with the specified
JSON Patch
|
| Modifier and Type | Method and Description |
|---|---|
JsonPatchBuilder |
add(String path,
boolean value)
Adds an "add" JSON Patch operation
|
JsonPatchBuilder |
add(String path,
int value)
Adds an "add" JSON Patch operation
|
JsonPatchBuilder |
add(String path,
JsonValue value)
Adds an "add" JSON Patch operation.
|
JsonPatchBuilder |
add(String path,
String value)
Adds an "add" JSON Patch operation
|
JsonArray |
apply(JsonArray target)
A convenience method for
build().apply(target) |
JsonObject |
apply(JsonObject target)
A convenience method for
build().apply(target) |
JsonStructure |
apply(JsonStructure target)
A convenience method for
new JsonPatch(build()).apply(target) |
JsonArray |
build()
Returns the patch operations in a JsonArray
|
JsonPatchBuilder |
copy(String path,
String from)
Adds a "copy" JSON Patch operation.
|
JsonPatchBuilder |
move(String path,
String from)
Adds a "move" JSON Patch operation.
|
JsonPatchBuilder |
remove(String path)
Adds a "remove" JSON Patch operation.
|
JsonPatchBuilder |
replace(String path,
boolean value)
Adds a "replace" JSON Patch operation.
|
JsonPatchBuilder |
replace(String path,
int value)
Adds a "replace" JSON Patch operation.
|
JsonPatchBuilder |
replace(String path,
JsonValue value)
Adds a "replace" JSON Patch operation.
|
JsonPatchBuilder |
replace(String path,
String value)
Adds a "replace" JSON Patch operation.
|
JsonPatchBuilder |
test(String path,
boolean value)
Adds a "test" JSON Patch operation.
|
JsonPatchBuilder |
test(String path,
int value)
Adds a "test" JSON Patch operation.
|
JsonPatchBuilder |
test(String path,
JsonValue value)
Adds a "test" JSON Patch operation.
|
JsonPatchBuilder |
test(String path,
String value)
Adds a "test" JSON Patch operation.
|
public JsonPatchBuilder(JsonArray patch)
patch - the JSON Patchpublic JsonPatchBuilder()
public JsonStructure apply(JsonStructure target)
new JsonPatch(build()).apply(target) target - the target to apply the patch operationsJsonException - if the supplied JSON Patch is malformed or if
it contains references to non-existing memberspublic JsonObject apply(JsonObject target)
build().apply(target) target - the target to apply the patch operationsJsonException - if the supplied JSON Patch is malformed or if
it contains references to non-existing membersapply(JsonStructure)public JsonArray apply(JsonArray target)
build().apply(target) target - the target to apply the patch operationsJsonException - if the supplied JSON Patch is malformed or if
it contains references to non-existing membersapply(JsonStructure)public JsonPatchBuilder add(String path, JsonValue value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder add(String path, String value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder add(String path, int value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder add(String path, boolean value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder remove(String path)
path - the "path" member of the operationpublic JsonPatchBuilder replace(String path, JsonValue value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder replace(String path, String value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder replace(String path, int value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder replace(String path, boolean value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder move(String path, String from)
path - the "path" member of the operationfrom - the "from" member of the operationpublic JsonPatchBuilder copy(String path, String from)
path - the "path" member of the operationfrom - the "from" member of the operationpublic JsonPatchBuilder test(String path, JsonValue value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder test(String path, String value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder test(String path, int value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonPatchBuilder test(String path, boolean value)
path - the "path" member of the operationvalue - the "value" member of the operationpublic JsonArray build()
Copyright © 2012-2015, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.
Comments to : users@json-processing-spec.java.net