Package com.jayway.jsonpath.spi.json
Class JettisonProvider
java.lang.Object
com.jayway.jsonpath.spi.json.AbstractJsonProvider
com.jayway.jsonpath.spi.json.JettisonProvider
- All Implemented Interfaces:
JsonProvider
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classJSON Array implementationprivate static classprivate static classJSON Object implementationprivate static classprivate static classJSON Object implementation -
Field Summary
Fields inherited from interface com.jayway.jsonpath.spi.json.JsonProvider
UNDEFINED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionIterable<?> Creates a provider specific json arrayCreates a provider specific json objectgetArrayIndex(Object obj, int index) 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.private static ObjectjettisonUnwrap(Object obj) private static ObjectjettisonWrap(Object obj) intGet the length of an array or objectprivate Objectparse(JettisonProvider.JettisonTokener JsonTokener) parse(InputStream jsonStream, String charset) Parse the given json stringParse the given json stringvoidremoveProperty(Object obj, Object key) Removes a value in an object or arrayvoidsetArrayIndex(Object array, int index, Object value) Sets a value in an array.voidsetProperty(Object obj, Object key, Object value) Sets a value in an objectIterable<?> toIterable(Object obj) Converts given array to anIterableConvert given json object to a json stringExtracts a value from a wrapper object.Methods inherited from class com.jayway.jsonpath.spi.json.AbstractJsonProvider
getArrayIndexMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.jayway.jsonpath.spi.json.JsonProvider
parse
-
Constructor Details
-
JettisonProvider
public JettisonProvider()
-
-
Method Details
-
jettisonUnwrap
-
jettisonWrap
-
parse
-
parse
Description copied from interface:JsonProviderParse the given json string- Parameters:
json- json string to parse- Returns:
- Object representation of json
- Throws:
InvalidJsonException
-
parse
Description copied from interface:JsonProviderParse the given json string- Parameters:
jsonStream- input stream to parsecharset- charset to use- Returns:
- Object representation of json
- Throws:
InvalidJsonException
-
toJson
Description copied from interface:JsonProviderConvert given json object to a json string- Parameters:
obj- object to transform- Returns:
- json representation of object
-
createMap
Description copied from interface:JsonProviderCreates a provider specific json object- Returns:
- new object
-
createArray
Description copied from interface:JsonProviderCreates a provider specific json array- Returns:
- new 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- Overrides:
unwrapin classAbstractJsonProvider- Parameters:
obj- a value holder object- Returns:
- the unwrapped value.
-
isArray
Description copied from class:AbstractJsonProviderchecks if object is an array- Specified by:
isArrayin interfaceJsonProvider- Overrides:
isArrayin classAbstractJsonProvider- Parameters:
obj- object to check- Returns:
- true if obj is an array
-
isMap
Description copied from class:AbstractJsonProviderchecks if object is a map (i.e. no array)- Specified by:
isMapin interfaceJsonProvider- Overrides:
isMapin classAbstractJsonProvider- Parameters:
obj- object to check- Returns:
- true if the object is a map
-
length
Description copied from class:AbstractJsonProviderGet the length of an array or object- Specified by:
lengthin interfaceJsonProvider- Overrides:
lengthin classAbstractJsonProvider- Parameters:
obj- an array or an object- Returns:
- the number of entries in the array or object
-
toIterable
Description copied from class:AbstractJsonProviderConverts given array to anIterable- Specified by:
toIterablein interfaceJsonProvider- Overrides:
toIterablein classAbstractJsonProvider- Parameters:
obj- an array- Returns:
- an Iterable that iterates over the entries of an array
-
getPropertyKeys
Description copied from class:AbstractJsonProviderReturns the keys from the given object- Specified by:
getPropertyKeysin interfaceJsonProvider- Overrides:
getPropertyKeysin classAbstractJsonProvider- Parameters:
obj- an object- Returns:
- the keys for an object
-
getArrayIndex
Description copied from class:AbstractJsonProviderExtracts a value from an array- Specified by:
getArrayIndexin interfaceJsonProvider- Overrides:
getArrayIndexin classAbstractJsonProvider- Parameters:
obj- an arrayindex- index- 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- Overrides:
setArrayIndexin classAbstractJsonProvider- Parameters:
array- an arrayindex- indexvalue- the new value
-
getMapValue
Description copied from class:AbstractJsonProviderExtracts a value from an map- Specified by:
getMapValuein interfaceJsonProvider- Overrides:
getMapValuein classAbstractJsonProvider- Parameters:
obj- a mapkey- property key- Returns:
- the map entry or
JsonProvider.UNDEFINEDfor missing properties
-
setProperty
Description copied from class:AbstractJsonProviderSets a value in an object- Specified by:
setPropertyin interfaceJsonProvider- Overrides:
setPropertyin classAbstractJsonProvider- Parameters:
obj- an objectkey- a String keyvalue- the value to set
-
removeProperty
Description copied from class:AbstractJsonProviderRemoves a value in an object or array- Specified by:
removePropertyin interfaceJsonProvider- Overrides:
removePropertyin classAbstractJsonProvider- Parameters:
obj- an array or an objectkey- a String key or a numerical index to remove
-