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 JsonProvider
UNDEFINED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetArrayIndex(Object obj, int idx) Extracts a value from an arrayfinal ObjectgetArrayIndex(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 objectbooleanchecks if object is an arraybooleanchecks if object is a map (i.e.intGet the length of an array or objectvoidremoveProperty(Object obj, Object key) Removes a value in an object or arrayvoidsetArrayIndex(Object array, int index, Object newValue) Sets a value in an array.voidsetProperty(Object obj, Object key, Object value) Sets a value in an objecttoIterable(Object obj) Converts given array to anIterableExtracts a value from a wrapper object.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface JsonProvider
createArray, createMap, parse, parse, toJson
-
Constructor Details
-
AbstractJsonProvider
public AbstractJsonProvider()
-
-
Method Details
-
isArray
checks if object is an array- Specified by:
isArrayin interfaceJsonProvider- Parameters:
obj- object to check- Returns:
- true if obj is an array
-
getArrayIndex
Extracts a value from an array- Specified by:
getArrayIndexin interfaceJsonProvider- Parameters:
obj- an arrayidx- index- Returns:
- the entry at the given index
-
getArrayIndex
Description copied from interface:JsonProviderExtracts a value from an array- Specified by:
getArrayIndexin 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:JsonProviderSets a value in an array. If the array is too small, the provider is supposed to enlarge it.- Specified by:
setArrayIndexin interfaceJsonProvider- Parameters:
array- an arrayindex- indexnewValue- the new value
-
getMapValue
Extracts a value from an map- Specified by:
getMapValuein interfaceJsonProvider- Parameters:
obj- a mapkey- property key- Returns:
- the map entry or
JsonProvider.UNDEFINEDfor missing properties
-
setProperty
Sets a value in an object- Specified by:
setPropertyin interfaceJsonProvider- Parameters:
obj- an objectkey- a String keyvalue- the value to set
-
removeProperty
Removes a value in an object or array- Specified by:
removePropertyin 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:
isMapin interfaceJsonProvider- Parameters:
obj- object to check- Returns:
- true if the object is a map
-
getPropertyKeys
Returns the keys from the given object- Specified by:
getPropertyKeysin interfaceJsonProvider- Parameters:
obj- an object- Returns:
- the keys for an object
-
length
Get the length of an array or object- Specified by:
lengthin 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:
toIterablein interfaceJsonProvider- Parameters:
obj- an array- Returns:
- an Iterable that iterates over the entries of an array
-
unwrap
Description copied from interface:JsonProviderExtracts a value from a wrapper object. For JSON providers that to not wrap values, this will usually be the object itself.- Specified by:
unwrapin interfaceJsonProvider- Parameters:
obj- a value holder object- Returns:
- the unwrapped value.
-