public final class JsonObject extends JsonObjectOrArray
Constructor and Description |
---|
JsonObject() |
Modifier and Type | Method and Description |
---|---|
JsonObject |
add(java.lang.String name,
java.lang.Object value) |
JsonArray |
addChildArray(java.lang.String name) |
JsonObject |
addChildObject(java.lang.String name) |
boolean |
containsKey(java.lang.String keyName)
Return true if the object contains the specified key, false otherwise.
|
java.lang.Object |
get(java.lang.String name)
Return the value of the specified key.
|
boolean |
getBoolean(java.lang.String name) |
boolean |
getBooleanOrDefault(java.lang.String name,
boolean defaultValue) |
double |
getDouble(java.lang.String name) |
double |
getDoubleOrDefault(java.lang.String name,
double defaultValue) |
java.lang.Double |
getDoubleOrNull(java.lang.String name) |
int |
getInt(java.lang.String name) |
int |
getIntOrDefault(java.lang.String name,
int defaultValue) |
JsonArray |
getJsonArray(java.lang.String name) |
JsonArray |
getJsonArrayOrNull(java.lang.String name) |
JsonObject |
getJsonObject(java.lang.String name) |
JsonObject |
getJsonObjectOrNull(java.lang.String name) |
long |
getLong(java.lang.String name) |
long |
getLongOrDefault(java.lang.String name,
long defaultValue) |
java.lang.String |
getName(int index)
Get name at the specified index.
|
java.lang.Object |
getOrNull(java.lang.String name)
Return the value of the specified key.
|
java.lang.String |
getString(java.lang.String name) |
java.lang.String |
getStringOrDefault(java.lang.String name,
java.lang.String defaultValue) |
java.lang.String |
getStringOrNull(java.lang.String name) |
java.lang.Object |
getValue(int index)
Get value at the specified index.
|
int |
size()
Get number of name/value pairs in the object.
|
toString, toUtf8Bytes, write
public int size()
public java.lang.String getName(int index)
index
- index in question; must be < size()public java.lang.Object getValue(int index)
index
- index in question; must be < size()public java.lang.Object get(java.lang.String name)
name
- key name@Nullable public java.lang.Object getOrNull(java.lang.String name)
name
- key namepublic boolean getBoolean(java.lang.String name)
public boolean getBooleanOrDefault(java.lang.String name, boolean defaultValue)
public java.lang.String getString(java.lang.String name)
@Nullable public java.lang.String getStringOrNull(java.lang.String name)
public java.lang.String getStringOrDefault(java.lang.String name, java.lang.String defaultValue)
public int getInt(java.lang.String name)
public int getIntOrDefault(java.lang.String name, int defaultValue)
public long getLong(java.lang.String name)
public long getLongOrDefault(java.lang.String name, long defaultValue)
public double getDouble(java.lang.String name)
@Nullable public java.lang.Double getDoubleOrNull(java.lang.String name)
public double getDoubleOrDefault(java.lang.String name, double defaultValue)
public JsonObject getJsonObject(java.lang.String name)
@Nullable public JsonObject getJsonObjectOrNull(java.lang.String name)
public JsonArray getJsonArray(java.lang.String name)
@Nullable public JsonArray getJsonArrayOrNull(java.lang.String name)
public boolean containsKey(java.lang.String keyName)
keyName
- key keyNamepublic JsonObject add(java.lang.String name, java.lang.Object value)
public JsonObject addChildObject(java.lang.String name)
public JsonArray addChildArray(java.lang.String name)