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

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    An enumeration of the known JsonFields of a Thing.
    static enum 
    Enumeration defining the supported JSON Patch operation types.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the JSON Patch operation type.
    Returns the path within the JSON Object on which the operation is defined.
    Returns the value to be used for the specified operation on the given path, if applicable, or an empty Optional otherwise.
    static JsonPatch
    Returns a new JSON Patch which can be used to specify modifications on JSON Objects.
    Returns the JSON object representation of this JSON Patch.
    Returns the JSON string for this JSON Patch in its minimal form, without any additional whitespace.
  • Method Details

    • 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:
      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

      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

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