public class JsonSmartJsonProvider extends Object implements JsonProvider
JsonProvider implementation for json-smart.JSONObject,
JSONArray| Constructor and Description |
|---|
JsonSmartJsonProvider() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Object jsonArray,
Object element)
Appends the specified element to the end of the specified JSON array.
|
boolean |
arrayContains(Object jsonArray,
Object element)
Checks if the specified JSON array contains the specified element.
|
Set<Map.Entry<String,Object>> |
entrySet(Object jsonObject)
Returns a
Set view of the mappings contained in the specified JSON object. |
void |
forEachElementInArray(Object jsonArray,
Consumer<? super Object> action)
Performs the given action for each element of the specified JSON array until all
entries have been processed.
|
Object |
get(Object jsonObject,
String key)
Returns the value to which the specified key is mapped in the specified JSON object; or
null if the JSON does not contain the specified key. |
boolean |
isEmpty(Object jsonObject)
Checks if the specified JSON object contains no data.
|
boolean |
isJsonArray(Object object)
Checks if the specified object is a JSON array for this provider.
|
boolean |
isJsonObject(Object object)
Checks if the specified object is a JSON object for this provider.
|
Object |
newJsonArray()
Creates a provider-specific JSON array.
|
Object |
newJsonArray(Object sourceJsonArray)
Creates a new provider-specific JSON array with the elements of a preset JSON array.
|
Object |
newJsonObject()
Creates a provider-specific JSON object.
|
Object |
newJsonObject(Object sourceJsonObject)
Creates a new provider-specific JSON object with the contents of a preset JSON object.
|
void |
put(Object jsonObject,
String key,
Object value)
Associates the specified value with the specified key in the specified JSON object.
|
void |
putIfAbsent(Object jsonObject,
String key,
Object value)
Associates the specified value with the specified key in the specified JSON object,
provided that the specified key is not already associated with a value in the JSON.
|
Stream<Object> |
stream(Object jsonArray)
Returns a sequential
Stream with the specified JSON array as its source. |
public boolean isJsonObject(Object object)
JsonProviderisJsonObject in interface JsonProviderobject - the object to be checkedtrue if the specified object is a provider-specific JSON object;
otherwise, false.public boolean isJsonArray(Object object)
JsonProviderisJsonArray in interface JsonProviderobject - the object to be checkedtrue if the specified object is a provider-specific JSON array;
otherwise, false.public boolean isEmpty(Object jsonObject)
JsonProviderisEmpty in interface JsonProviderjsonObject - the JSON object to be checked; not nulltrue if the specified JSON object contains no data; otherwise,
false.public Object newJsonObject()
JsonProvidernewJsonObject in interface JsonProviderpublic Object newJsonObject(Object sourceJsonObject)
JsonProviderNote: The resulting object is supposed to be shallow copy of the source JSON object.
newJsonObject in interface JsonProvidersourceJsonObject - the JSON whose contents are to be copied; not nullpublic Object newJsonArray()
JsonProvidernewJsonArray in interface JsonProviderpublic Object newJsonArray(Object sourceJsonArray)
JsonProviderNote: Although the actual implementation may vary depending on the concrete provider, the resulting object is supposed to be shallow copy of the source JSON array.
newJsonArray in interface JsonProvidersourceJsonArray - the JSON array whose contents are to be copied; not nullpublic Set<Map.Entry<String,Object>> entrySet(Object jsonObject)
JsonProviderSet view of the mappings contained in the specified JSON object.entrySet in interface JsonProviderjsonObject - the JSON object whose entries shall be accessed; not nullpublic Object get(Object jsonObject, String key)
JsonProvidernull if the JSON does not contain the specified key.get in interface JsonProviderjsonObject - the JSON object; not nullkey - the key to be searched; not nullpublic void put(Object jsonObject, String key, Object value)
JsonProviderput in interface JsonProviderjsonObject - the JSON object; not nullkey - the key with which the specified value is to be associated in the
JSON; not nullvalue - the value to be associated with the specified key in the JSONpublic void putIfAbsent(Object jsonObject, String key, Object value)
JsonProviderputIfAbsent in interface JsonProviderjsonObject - the JSON object; not nullkey - the key with which the specified value is to be associated in the
JSON; not nullvalue - the value to be associated with the specified key in the JSON,
provided that the specified key is absent in the documentpublic void add(Object jsonArray, Object element)
JsonProvideradd in interface JsonProviderjsonArray - the JSON array; not nullelement - the element to be addedpublic void forEachElementInArray(Object jsonArray, Consumer<? super Object> action)
JsonProviderforEachElementInArray in interface JsonProviderjsonArray - the JSON array; not nullaction - the action to be performed for each element; not nullpublic boolean arrayContains(Object jsonArray, Object element)
JsonProviderarrayContains in interface JsonProviderjsonArray - the JSON array; not nullelement - the element to be searchedtrue if the specified JSON array contains the specified element;
otherwise, false.public Stream<Object> stream(Object jsonArray)
JsonProviderStream with the specified JSON array as its source.stream in interface JsonProviderjsonArray - the JSON array; not nullStream over the elements in this JSON arrayCopyright © 2022. All rights reserved.