public interface WriteContext
Modifier and Type | Method and Description |
---|---|
DocumentContext |
add(JsonPath path,
Object value)
Add value to array at the given path
|
DocumentContext |
add(String path,
Object value,
Predicate... filters)
Add value to array
|
Configuration |
configuration()
Returns the configuration used for reading
|
DocumentContext |
delete(JsonPath path)
Deletes the given path
|
DocumentContext |
delete(String path,
Predicate... filters)
Deletes the given path
|
<T> T |
json()
Returns the JSON model that this context is operating on
|
String |
jsonString()
Returns the JSON model that this context is operating on as a JSON string
|
DocumentContext |
map(JsonPath path,
MapFunction mapFunction)
Replaces the value on the given path with the result of the
MapFunction . |
DocumentContext |
map(String path,
MapFunction mapFunction,
Predicate... filters)
Replaces the value on the given path with the result of the
MapFunction . |
DocumentContext |
put(JsonPath path,
String key,
Object value)
Add or update the key with a the given value at the given path
|
DocumentContext |
put(String path,
String key,
Object value,
Predicate... filters)
Add or update the key with a the given value at the given path
|
DocumentContext |
renameKey(JsonPath path,
String oldKeyName,
String newKeyName)
Renames the last key element of a given path.
|
DocumentContext |
renameKey(String path,
String oldKeyName,
String newKeyName,
Predicate... filters)
Renames the last key element of a given path.
|
DocumentContext |
set(JsonPath path,
Object newValue)
Set the value a the given path
|
DocumentContext |
set(String path,
Object newValue,
Predicate... filters)
Set the value a the given path
|
Configuration configuration()
<T> T json()
String jsonString()
DocumentContext set(String path, Object newValue, Predicate... filters)
path
- path to setnewValue
- new valuefilters
- filtersDocumentContext set(JsonPath path, Object newValue)
path
- path to setnewValue
- new valueDocumentContext map(String path, MapFunction mapFunction, Predicate... filters)
MapFunction
.path
- path to be converted setmapFunction
- Converter object to be invokedfilters
- filtersDocumentContext map(JsonPath path, MapFunction mapFunction)
MapFunction
.path
- path to be converted setmapFunction
- Converter object to be invoked (or lambda:))DocumentContext delete(String path, Predicate... filters)
path
- path to deletefilters
- filtersDocumentContext delete(JsonPath path)
path
- path to deleteDocumentContext add(String path, Object value, Predicate... filters)
List array = new ArrayList(){{
add(0);
add(1);
}};
JsonPath.parse(array).add("$", 2);
assertThat(array).containsExactly(0,1,2);
path
- path to arrayvalue
- value to addfilters
- filtersDocumentContext add(JsonPath path, Object value)
path
- path to arrayvalue
- value to addDocumentContext put(String path, String key, Object value, Predicate... filters)
path
- path to objectkey
- key to addvalue
- value of keyfilters
- filtersDocumentContext put(JsonPath path, String key, Object value)
path
- path to arraykey
- key to addvalue
- value of keyDocumentContext renameKey(String path, String oldKeyName, String newKeyName, Predicate... filters)
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.DocumentContext renameKey(JsonPath path, String oldKeyName, String newKeyName)
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.Copyright © 2019. All rights reserved.