Package com.jayway.jsonpath
Interface WriteContext
- All Known Subinterfaces:
DocumentContext
- All Known Implementing Classes:
JsonContext
public interface WriteContext
-
Method Summary
Modifier and TypeMethodDescriptionAdd value to array at the given pathAdd value to arrayReturns the configuration used for readingDeletes the given pathDeletes the given path<T> T
json()
Returns the JSON model that this context is operating onReturns the JSON model that this context is operating on as a JSON stringmap
(JsonPath path, MapFunction mapFunction) Replaces the value on the given path with the result of theMapFunction
.map
(String path, MapFunction mapFunction, Predicate... filters) Replaces the value on the given path with the result of theMapFunction
.Add or update the key with a the given value at the given pathAdd or update the key with a the given value at the given pathRenames the last key element of a given path.Renames the last key element of a given path.Set the value a the given pathSet the value a the given path
-
Method Details
-
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
String jsonString()Returns the JSON model that this context is operating on as a JSON string- Returns:
- json model as string
-
set
Set the value a the given path- Parameters:
path
- path to setnewValue
- new valuefilters
- filters- Returns:
- a document context
-
set
Set the value a the given path- Parameters:
path
- path to setnewValue
- new value- Returns:
- a document context
-
map
Replaces the value on the given path with the result of theMapFunction
.- Parameters:
path
- path to be converted setmapFunction
- Converter object to be invokedfilters
- filters- Returns:
- a document context
-
map
Replaces the value on the given path with the result of theMapFunction
.- Parameters:
path
- path to be converted setmapFunction
- Converter object to be invoked (or lambda:))- Returns:
- a document context
-
delete
Deletes the given path- Parameters:
path
- path to deletefilters
- filters- Returns:
- a document context
-
delete
Deletes the given path- Parameters:
path
- path to delete- Returns:
- a document context
-
add
Add value to arrayList
array = new ArrayList (){{ add(0); add(1); }}; JsonPath.parse(array).add("$", 2); assertThat(array).containsExactly(0,1,2); - Parameters:
path
- path to arrayvalue
- value to addfilters
- filters- Returns:
- a document context
-
add
Add value to array at the given path- Parameters:
path
- path to arrayvalue
- value to add- Returns:
- a document context
-
put
Add or update the key with a the given value at the given path- Parameters:
path
- path to objectkey
- key to addvalue
- value of keyfilters
- filters- Returns:
- a document context
-
put
Add or update the key with a the given value at the given path- Parameters:
path
- path to arraykey
- key to addvalue
- value of key- Returns:
- a document context
-
renameKey
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
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.
-