Package org.eclipse.ditto.json
Interface JsonPatch
public interface JsonPatch
Defines a JSON Patch which can be used to specify modifications on JSON Objects. For example, the following
patch defines an insertion operation on path "address/city" with value "Berlin".
{ "op": "add", "path": "address/city", "value": "Berlin" }
Implementations of this interface are required to be immutable!
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic final class
An enumeration of the knownJsonField
s of a Thing.static enum
Enumeration defining the supported JSON Patch operation types. -
Method Summary
Modifier and TypeMethodDescriptionReturns the JSON Patch operation type.getPath()
Returns the path within the JSON Object on which the operation is defined.getValue()
Returns the value to be used for the specified operation on the given path, if applicable, or an emptyOptional
otherwise.static JsonPatch
newInstance
(JsonPatch.Operation operation, JsonPointer path, JsonValue value) Returns a new JSON Patch which can be used to specify modifications on JSON Objects.toJson()
Returns the JSON object representation of this JSON Patch.toString()
Returns the JSON string for this JSON Patch in its minimal form, without any additional whitespace.
-
Method Details
-
newInstance
Returns a new JSON Patch which can be used to specify modifications on JSON Objects.- Parameters:
operation
- the patch operation typepath
- a JSON Pointer specifying the path within the JSON Object on which the operation is definedvalue
- the value to be used for the specified operation on the given path- Returns:
- the new JSON Patch.
- Throws:
NullPointerException
- ifoperation
orpath
isnull
.
-
getOperation
JsonPatch.Operation getOperation()Returns the JSON Patch operation type.- Returns:
Operation
-
getPath
JsonPointer getPath()Returns the path within the JSON Object on which the operation is defined.- Returns:
- the path.
-
getValue
Returns the value to be used for the specified operation on the given path, if applicable, or an emptyOptional
otherwise.- Returns:
- the value.
-
toJson
JsonObject toJson()Returns the JSON object representation of this JSON Patch.- Returns:
- the JSON object representation of this patch.
-
toString
String toString()Returns the JSON string for this JSON Patch in its minimal form, without any additional whitespace.
-