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!

    • Method Detail

      • newInstance

        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.
        Parameters:
        operation - the patch operation type
        path - a JSON Pointer specifying the path within the JSON Object on which the operation is defined
        value - the value to be used for the specified operation on the given path
        Returns:
        the new JSON Patch.
        Throws:
        java.lang.NullPointerException - if operation or path is null.
      • 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

        java.util.Optional<JsonValue> getValue()
        Returns the value to be used for the specified operation on the given path, if applicable, or an empty Optional 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

        java.lang.String toString()
        Returns the JSON string for this JSON Patch in its minimal form, without any additional whitespace.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a JSON string that represents this JSON Patch.