public interface JsonProvider
Modifier and Type | Method and Description |
---|---|
Object |
createArray()
Creates a provider specific json array
|
Object |
createMap()
Creates a provider specific json object
|
Object |
getArrayIndex(Object obj,
int idx)
Extracts a value from an array anw unwraps provider specific data type
|
Object |
getArrayIndex(Object obj,
int idx,
boolean unwrap)
Deprecated.
|
Object |
getMapValue(Object obj,
String key)
Extracts a value from an map
|
Collection<String> |
getPropertyKeys(Object obj)
Returns the keys from the given object
|
boolean |
isArray(Object obj)
checks if object is an array
|
boolean |
isMap(Object obj)
checks if object is a map (i.e.
|
int |
length(Object obj)
Get the length of an json array, json object or a json string
|
Object |
parse(InputStream jsonStream,
String charset)
Parse the given json string
|
Object |
parse(String json)
Parse the given json string
|
void |
removeProperty(Object obj,
Object key)
Removes a value in an object or array
|
void |
setArrayIndex(Object array,
int idx,
Object newValue)
Sets a value in an array.
|
void |
setProperty(Object obj,
Object key,
Object value)
Sets a value in an object
|
Iterable<?> |
toIterable(Object obj)
Converts given array to an
Iterable |
String |
toJson(Object obj)
Convert given json object to a json string
|
Object |
unwrap(Object obj)
Extracts a value from a wrapper object.
|
static final Object UNDEFINED
Object parse(String json) throws InvalidJsonException
json
- json string to parseInvalidJsonException
Object parse(InputStream jsonStream, String charset) throws InvalidJsonException
jsonStream
- input stream to parsecharset
- charset to useInvalidJsonException
String toJson(Object obj)
obj
- object to transformObject createArray()
Object createMap()
boolean isArray(Object obj)
obj
- object to checkint length(Object obj)
obj
- an array or object or a stringIterable<?> toIterable(Object obj)
Iterable
obj
- an arrayCollection<String> getPropertyKeys(Object obj)
obj
- an objectObject getArrayIndex(Object obj, int idx)
obj
- an arrayidx
- index@Deprecated Object getArrayIndex(Object obj, int idx, boolean unwrap)
obj
- an arrayidx
- indexunwrap
- should provider specific data type be unwrappedvoid setArrayIndex(Object array, int idx, Object newValue)
array
- an arrayidx
- indexnewValue
- the new valueObject getMapValue(Object obj, String key)
obj
- a mapkey
- property keyUNDEFINED
for missing propertiesvoid setProperty(Object obj, Object key, Object value)
obj
- an objectkey
- a String keyvalue
- the value to setvoid removeProperty(Object obj, Object key)
obj
- an array or an objectkey
- a String key or a numerical index to removeboolean isMap(Object obj)
obj
- object to checkCopyright © 2021. All rights reserved.