Package com.jayway.jsonpath.spi.json
Class AbstractJsonProvider
java.lang.Object
com.jayway.jsonpath.spi.json.AbstractJsonProvider
- All Implemented Interfaces:
JsonProvider
- Direct Known Subclasses:
GsonJsonProvider
,JacksonJsonNodeJsonProvider
,JacksonJsonProvider
,JsonSmartJsonProvider
-
Field Summary
Fields inherited from interface com.jayway.jsonpath.spi.json.JsonProvider
UNDEFINED
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetArrayIndex
(Object obj, int idx) Extracts a value from an arrayfinal Object
getArrayIndex
(Object obj, int idx, boolean unwrap) Extracts a value from an arraygetMapValue
(Object obj, String key) Extracts a value from an mapgetPropertyKeys
(Object obj) Returns the keys from the given objectboolean
checks if object is an arrayboolean
checks if object is a map (i.e.int
Get the length of an array or objectvoid
removeProperty
(Object obj, Object key) Removes a value in an object or arrayvoid
setArrayIndex
(Object array, int index, Object newValue) Sets a value in an array.void
setProperty
(Object obj, Object key, Object value) Sets a value in an objecttoIterable
(Object obj) Converts given array to anIterable
Extracts a value from a wrapper object.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jayway.jsonpath.spi.json.JsonProvider
createArray, createMap, parse, parse, toJson
-
Constructor Details
-
AbstractJsonProvider
public AbstractJsonProvider()
-
-
Method Details
-
isArray
checks if object is an array- Specified by:
isArray
in interfaceJsonProvider
- Parameters:
obj
- object to check- Returns:
- true if obj is an array
-
getArrayIndex
Extracts a value from an array- Specified by:
getArrayIndex
in interfaceJsonProvider
- Parameters:
obj
- an arrayidx
- index- Returns:
- the entry at the given index
-
getArrayIndex
Description copied from interface:JsonProvider
Extracts a value from an array- Specified by:
getArrayIndex
in interfaceJsonProvider
- Parameters:
obj
- an arrayidx
- indexunwrap
- should provider specific data type be unwrapped- Returns:
- the entry at the given index
-
setArrayIndex
Description copied from interface:JsonProvider
Sets a value in an array. If the array is too small, the provider is supposed to enlarge it.- Specified by:
setArrayIndex
in interfaceJsonProvider
- Parameters:
array
- an arrayindex
- indexnewValue
- the new value
-
getMapValue
Extracts a value from an map- Specified by:
getMapValue
in interfaceJsonProvider
- Parameters:
obj
- a mapkey
- property key- Returns:
- the map entry or
JsonProvider.UNDEFINED
for missing properties
-
setProperty
Sets a value in an object- Specified by:
setProperty
in interfaceJsonProvider
- Parameters:
obj
- an objectkey
- a String keyvalue
- the value to set
-
removeProperty
Removes a value in an object or array- Specified by:
removeProperty
in interfaceJsonProvider
- Parameters:
obj
- an array or an objectkey
- a String key or a numerical index to remove
-
isMap
checks if object is a map (i.e. no array)- Specified by:
isMap
in interfaceJsonProvider
- Parameters:
obj
- object to check- Returns:
- true if the object is a map
-
getPropertyKeys
Returns the keys from the given object- Specified by:
getPropertyKeys
in interfaceJsonProvider
- Parameters:
obj
- an object- Returns:
- the keys for an object
-
length
Get the length of an array or object- Specified by:
length
in interfaceJsonProvider
- Parameters:
obj
- an array or an object- Returns:
- the number of entries in the array or object
-
toIterable
Converts given array to anIterable
- Specified by:
toIterable
in interfaceJsonProvider
- Parameters:
obj
- an array- Returns:
- an Iterable that iterates over the entries of an array
-
unwrap
Description copied from interface:JsonProvider
Extracts a value from a wrapper object. For JSON providers that to not wrap values, this will usually be the object itself.- Specified by:
unwrap
in interfaceJsonProvider
- Parameters:
obj
- a value holder object- Returns:
- the unwrapped value.
-