public class GsonJsonProvider extends AbstractJsonProvider<com.google.gson.JsonObject>
JsonProvider implementation for Gson.JsonObject,
JsonArray| Constructor and Description |
|---|
GsonJsonProvider() |
| 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 jsonArray,
int index)
Returns the element at the specified position in the specified JSON array.
|
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. |
int |
indexOf(Object jsonArray,
Object element)
Returns the index of the first occurrence of the specified element in the specified
JSON array, or -1 if there is no such index.
|
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.
|
com.google.gson.JsonObject |
newJsonObject()
Creates a provider-specific JSON object.
|
com.google.gson.JsonObject |
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.
|
void |
set(Object jsonArray,
int index,
Object element)
Replaces the element at the specified position in the JSON array with the specified
element.
|
int |
size(Object jsonArray)
Returns the number of elements in the specified JSON array.
|
Stream<Object> |
stream(Object jsonArray)
Returns a sequential
Stream with the specified JSON array as its source. |
equals, parse, parsepublic boolean isJsonObject(Object object)
JsonProviderobject - the object to be checkedtrue if the specified object is a provider-specific JSON object;
otherwise, false.public boolean isJsonArray(Object object)
JsonProviderobject - the object to be checkedtrue if the specified object is a provider-specific JSON array;
otherwise, false.public boolean isEmpty(Object jsonObject)
JsonProviderjsonObject - the JSON object to be checked; not nulltrue if the specified JSON object contains no data; otherwise,
false.public com.google.gson.JsonObject newJsonObject()
JsonProviderpublic com.google.gson.JsonObject newJsonObject(Object sourceJsonObject)
JsonProviderNote: The resulting object is supposed to be shallow copy of the source JSON object.
sourceJsonObject - the JSON whose contents are to be copied; not nullpublic Object newJsonArray()
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.
sourceJsonArray - 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.jsonObject - 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.jsonObject - the JSON object; not nullkey - the key to be searched; not nullpublic Object get(Object jsonArray, int index)
JsonProviderjsonArray - the JSON array; not nullindex - index of the element to returnpublic void put(Object jsonObject, String key, Object value)
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)
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)
JsonProviderjsonArray - the JSON array; not nullelement - the element to be addedpublic void set(Object jsonArray, int index, Object element)
JsonProviderjsonArray - the JSON array; not nullindex - the index of the element to replaceelement - the element to be stored at the specified positionpublic int indexOf(Object jsonArray, Object element)
JsonProviderjsonArray - the JSON array; not nullelement - the element to search forpublic void forEachElementInArray(Object jsonArray, Consumer<? super Object> action)
JsonProviderjsonArray - the JSON array; not nullaction - the action to be performed for each element; not nullpublic boolean arrayContains(Object jsonArray, Object element)
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.jsonArray - the JSON array; not nullStream over the elements in this JSON arraypublic int size(Object jsonArray)
JsonProviderjsonArray - the JSON array; not nullCopyright © 2025. All rights reserved.