public class JsonObject
extends java.util.HashMap<java.lang.String,java.lang.Object>
HashMap with helper methods to determine the underlying JSON type of the map element.| Constructor and Description |
|---|
JsonObject()
Creates an empty
JsonObject with the default capacity. |
JsonObject(int initialCapacity)
Creates a
JsonObject with the given initial capacity. |
JsonObject(int initialCapacity,
float loadFactor)
Creates a
JsonObject with the given initial capacity and load factor. |
JsonObject(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)
Creates a
JsonObject from an existing Map. |
| Modifier and Type | Method and Description |
|---|---|
static JsonBuilder<JsonObject> |
builder()
Creates a
JsonBuilder for a JsonObject. |
JsonArray |
getArray(java.lang.String key)
Returns the
JsonArray at the given key, or null if it does not exist or is the wrong type. |
JsonArray |
getArray(java.lang.String key,
JsonArray default_)
Returns the
JsonArray at the given key, or the default if it does not exist or is the wrong type. |
boolean |
getBoolean(java.lang.String key)
Returns the
Boolean at the given key, or false if it does not exist or is the wrong type. |
boolean |
getBoolean(java.lang.String key,
java.lang.Boolean default_)
Returns the
Boolean at the given key, or the default if it does not exist or is the wrong type. |
double |
getDouble(java.lang.String key)
Returns the
Double at the given key, or 0.0 if it does not exist or is the wrong type. |
double |
getDouble(java.lang.String key,
double default_)
Returns the
Double at the given key, or the default if it does not exist or is the wrong type. |
float |
getFloat(java.lang.String key)
Returns the
Float at the given key, or 0.0f if it does not exist or is the wrong type. |
float |
getFloat(java.lang.String key,
float default_)
Returns the
Float at the given key, or the default if it does not exist or is the wrong type. |
int |
getInt(java.lang.String key)
Returns the
Integer at the given key, or 0 if it does not exist or is the wrong type. |
int |
getInt(java.lang.String key,
int default_)
Returns the
Integer at the given key, or the default if it does not exist or is the wrong type. |
java.lang.Number |
getNumber(java.lang.String key)
Returns the
Number at the given key, or null if it does not exist or is the wrong type. |
java.lang.Number |
getNumber(java.lang.String key,
java.lang.Number default_)
Returns the
Number at the given key, or the default if it does not exist or is the wrong type. |
JsonObject |
getObject(java.lang.String key)
Returns the
JsonObject at the given key, or null if it does not exist or is the wrong type. |
JsonObject |
getObject(java.lang.String key,
JsonObject default_)
Returns the
JsonObject at the given key, or the default if it does not exist or is the wrong type. |
java.lang.String |
getString(java.lang.String key)
Returns the
String at the given key, or null if it does not exist or is the wrong type. |
java.lang.String |
getString(java.lang.String key,
java.lang.String default_)
Returns the
String at the given key, or the default if it does not exist or is the wrong type. |
boolean |
has(java.lang.String key)
Returns true if the object has an element at that key (even if that element is null).
|
boolean |
isBoolean(java.lang.String key)
Returns true if the object has a boolean element at that key.
|
boolean |
isNull(java.lang.String key)
Returns true if the object has a null element at that key.
|
boolean |
isNumber(java.lang.String key)
Returns true if the object has a number element at that key.
|
boolean |
isString(java.lang.String key)
Returns true if the object has a string element at that key.
|
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuespublic JsonObject()
JsonObject with the default capacity.public JsonObject(java.util.Map<? extends java.lang.String,? extends java.lang.Object> map)
JsonObject from an existing Map.public JsonObject(int initialCapacity)
JsonObject with the given initial capacity.public JsonObject(int initialCapacity,
float loadFactor)
JsonObject with the given initial capacity and load factor.public static JsonBuilder<JsonObject> builder()
JsonBuilder for a JsonObject.public JsonArray getArray(java.lang.String key)
JsonArray at the given key, or null if it does not exist or is the wrong type.public JsonArray getArray(java.lang.String key, JsonArray default_)
JsonArray at the given key, or the default if it does not exist or is the wrong type.public boolean getBoolean(java.lang.String key)
Boolean at the given key, or false if it does not exist or is the wrong type.public boolean getBoolean(java.lang.String key,
java.lang.Boolean default_)
Boolean at the given key, or the default if it does not exist or is the wrong type.public double getDouble(java.lang.String key)
Double at the given key, or 0.0 if it does not exist or is the wrong type.public double getDouble(java.lang.String key,
double default_)
Double at the given key, or the default if it does not exist or is the wrong type.public float getFloat(java.lang.String key)
Float at the given key, or 0.0f if it does not exist or is the wrong type.public float getFloat(java.lang.String key,
float default_)
Float at the given key, or the default if it does not exist or is the wrong type.public int getInt(java.lang.String key)
Integer at the given key, or 0 if it does not exist or is the wrong type.public int getInt(java.lang.String key,
int default_)
Integer at the given key, or the default if it does not exist or is the wrong type.public java.lang.Number getNumber(java.lang.String key)
Number at the given key, or null if it does not exist or is the wrong type.public java.lang.Number getNumber(java.lang.String key,
java.lang.Number default_)
Number at the given key, or the default if it does not exist or is the wrong type.public JsonObject getObject(java.lang.String key)
JsonObject at the given key, or null if it does not exist or is the wrong type.public JsonObject getObject(java.lang.String key, JsonObject default_)
JsonObject at the given key, or the default if it does not exist or is the wrong type.public java.lang.String getString(java.lang.String key)
String at the given key, or null if it does not exist or is the wrong type.public java.lang.String getString(java.lang.String key,
java.lang.String default_)
String at the given key, or the default if it does not exist or is the wrong type.public boolean has(java.lang.String key)
public boolean isBoolean(java.lang.String key)
public boolean isNull(java.lang.String key)
public boolean isNumber(java.lang.String key)
public boolean isString(java.lang.String key)