Interface WriteContext

    • Method Detail

      • configuration

        Configuration configuration()
        Returns the configuration used for reading
        Returns:
        an immutable configuration
      • json

        <T> T json()
        Returns the JSON model that this context is operating on
        Returns:
        json model
      • jsonString

        java.lang.String jsonString()
        Returns the JSON model that this context is operating on as a JSON string
        Returns:
        json model as string
      • set

        DocumentContext set​(java.lang.String path,
                            java.lang.Object newValue,
                            Predicate... filters)
        Set the value a the given path
        Parameters:
        path - path to set
        newValue - new value
        filters - filters
        Returns:
        a document context
      • set

        DocumentContext set​(JsonPath path,
                            java.lang.Object newValue)
        Set the value a the given path
        Parameters:
        path - path to set
        newValue - new value
        Returns:
        a document context
      • map

        DocumentContext map​(java.lang.String path,
                            MapFunction mapFunction,
                            Predicate... filters)
        Replaces the value on the given path with the result of the MapFunction.
        Parameters:
        path - path to be converted set
        mapFunction - Converter object to be invoked
        filters - filters
        Returns:
        a document context
      • map

        DocumentContext map​(JsonPath path,
                            MapFunction mapFunction)
        Replaces the value on the given path with the result of the MapFunction.
        Parameters:
        path - path to be converted set
        mapFunction - Converter object to be invoked (or lambda:))
        Returns:
        a document context
      • delete

        DocumentContext delete​(java.lang.String path,
                               Predicate... filters)
        Deletes the given path
        Parameters:
        path - path to delete
        filters - filters
        Returns:
        a document context
      • delete

        DocumentContext delete​(JsonPath path)
        Deletes the given path
        Parameters:
        path - path to delete
        Returns:
        a document context
      • add

        DocumentContext add​(java.lang.String path,
                            java.lang.Object value,
                            Predicate... filters)
        Add value to array
         
         List array = new ArrayList(){{
              add(0);
              add(1);
         }};
        
         JsonPath.parse(array).add("$", 2);
        
         assertThat(array).containsExactly(0,1,2);
         
         
        Parameters:
        path - path to array
        value - value to add
        filters - filters
        Returns:
        a document context
      • add

        DocumentContext add​(JsonPath path,
                            java.lang.Object value)
        Add value to array at the given path
        Parameters:
        path - path to array
        value - value to add
        Returns:
        a document context
      • put

        DocumentContext put​(java.lang.String path,
                            java.lang.String key,
                            java.lang.Object value,
                            Predicate... filters)
        Add or update the key with a the given value at the given path
        Parameters:
        path - path to object
        key - key to add
        value - value of key
        filters - filters
        Returns:
        a document context
      • put

        DocumentContext put​(JsonPath path,
                            java.lang.String key,
                            java.lang.Object value)
        Add or update the key with a the given value at the given path
        Parameters:
        path - path to array
        key - key to add
        value - value of key
        Returns:
        a document context
      • renameKey

        DocumentContext renameKey​(java.lang.String path,
                                  java.lang.String oldKeyName,
                                  java.lang.String newKeyName,
                                  Predicate... filters)
        Renames the last key element of a given path.
        Parameters:
        path - The path to the old key. Should be resolved to a map or an array including map items.
        oldKeyName - The old key name.
        newKeyName - The new key name.
        filters - filters.
        Returns:
        a document content.
      • renameKey

        DocumentContext renameKey​(JsonPath path,
                                  java.lang.String oldKeyName,
                                  java.lang.String newKeyName)
        Renames the last key element of a given path.
        Parameters:
        path - The path to the old key. Should be resolved to a map or an array including map items.
        oldKeyName - The old key name.
        newKeyName - The new key name.
        Returns:
        a document content.