Package javax.json

Interface JsonPointer


  • public interface JsonPointer

    This class is an immutable representation of a JSON Pointer as specified in RFC 6901.

    JSON Pointer is a string syntax for identifying a specific value within a JavaScript Object Notation (JSON) document [RFC4627]. JSON Pointer is intended to be easily expressed in JSON string values as well as Uniform Resource Identifier (URI) [RFC3986] fragment identifiers.

    The method getValue() returns the referenced value. The methods add(), replace(), and remove() executes the operations specified in RFC 6902.

    Since:
    1.1
    • Method Detail

      • getValue

        JsonValue getValue​(JsonStructure target)
        Get the JsonValue at the position referenced by this JsonPointer.
        Parameters:
        target - the JSON to apply this JsonPointer on
        Returns:
        the
        Throws:
        JsonException - if no value exists at the referenced location
        java.lang.NullPointerException - if the target is null
      • add

        <T extends JsonStructure> T add​(T target,
                                        JsonValue newValue)
        Add or replace the value at the position referenced by this JsonPointer with the new value
        Type Parameters:
        T -
        Parameters:
        target - structure in which the newValue should be added or replaced
        newValue - the new value to set
        Returns:
        the new structure after modifying the original JsonStrucure
        Throws:
        JsonException - if no value exists at the referenced location
        java.lang.NullPointerException - if the target is null
      • remove

        <T extends JsonStructure> T remove​(T target)
        Remove the value from the referenced position inside the target JSON.
        Type Parameters:
        T - the type of the passed JsonStructure
        Parameters:
        target - to remove the value from
        Returns:
        a new JsonStructure with the value removed from the target
        Throws:
        JsonException - if no value exists at the referenced location
        java.lang.NullPointerException - if the target is null
      • replace

        <T extends JsonStructure> T replace​(T target,
                                            JsonValue newValue)
        Replace the value at the position referenced by this JsonPointer with the newValue.
        Type Parameters:
        T -
        Parameters:
        target - structure in which the newValue should be replaced
        newValue - the new value to set
        Returns:
        the new structure after modifying the original JsonStrucure
        Throws:
        JsonException - if no value exists at the referenced location
        java.lang.NullPointerException - if the target is null
      • containsValue

        boolean containsValue​(JsonStructure target)
        Verify if the target JSON structure contains a value at the referenced location.
        Parameters:
        target - to check
        Returns:
        true if there is a value at the referenced location, false otherwise
        Throws:
        java.lang.NullPointerException - if the target is null