public class PJsonObject extends PAbstractObject
JSONObject class to have a better
error management.| Constructor and Description |
|---|
PJsonObject(org.json.JSONObject obj,
java.lang.String contextName)
Constructor.
|
PJsonObject(PElement parent,
org.json.JSONObject obj,
java.lang.String contextName)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
org.json.JSONObject |
getInternalObj()
Get the internal json object.
|
PJsonArray |
getJSONArray(java.lang.String key)
Get a property as a json array or throw exception.
|
PJsonObject |
getJSONObject(java.lang.String key)
Get a property as a json object or throw exception.
|
boolean |
has(java.lang.String key)
Check if the object has a property with the key.
|
int |
hashCode() |
boolean |
isArray(java.lang.String key)
Is the property an array.
|
java.util.Iterator<java.lang.String> |
keys()
Get an iterator of all keys in this objects.
|
java.lang.Object |
opt(java.lang.String key)
Get the value for the key.
|
PArray |
optArray(java.lang.String key)
Get a property as a array or null.
|
java.lang.Boolean |
optBool(java.lang.String key)
Get a property as a boolean or null.
|
java.lang.Double |
optDouble(java.lang.String key)
Get a property as a double or null.
|
java.lang.Float |
optFloat(java.lang.String key)
Get a property as a float or null.
|
java.lang.Integer |
optInt(java.lang.String key)
Get a property as a int or null.
|
PJsonArray |
optJSONArray(java.lang.String key)
Get a property as a json array or null.
|
PJsonArray |
optJSONArray(java.lang.String key,
PJsonArray defaultValue)
Get a property as a json array or default.
|
PJsonObject |
optJSONObject(java.lang.String key)
Get a property as a json object or null.
|
java.lang.Long |
optLong(java.lang.String key)
Get a property as a long or MIN_VALUE.
|
PObject |
optObject(java.lang.String key)
Get a property as a object or null.
|
java.lang.String |
optString(java.lang.String key)
Get a property as a string or null.
|
int |
size()
Get the number of properties in this object.
|
java.lang.String |
toString() |
getArray, getBool, getDouble, getFloat, getInt, getLong, getObject, getString, optArray, optBool, optDouble, optFloat, optInt, optLong, optObject, optStringaddPathTo, getContextName, getCurrentPath, getParent, getPathclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetCurrentPath, getPathpublic PJsonObject(org.json.JSONObject obj,
java.lang.String contextName)
obj - the internal json elementcontextName - the field name of this element in the parent.public PJsonObject(PElement parent, org.json.JSONObject obj, java.lang.String contextName)
parent - the parent elementobj - the internal json elementcontextName - the field name of this element in the parent.public final java.lang.Object opt(java.lang.String key)
PObjectkey - the key identifying the value to obtain.public final java.lang.String optString(java.lang.String key)
key - the property namepublic final java.lang.Integer optInt(java.lang.String key)
key - the property namepublic final java.lang.Long optLong(java.lang.String key)
PObjectkey - the property namepublic final java.lang.Double optDouble(java.lang.String key)
key - the property namepublic final java.lang.Float optFloat(java.lang.String key)
key - the property namepublic final java.lang.Boolean optBool(java.lang.String key)
key - the property namepublic final PObject optObject(java.lang.String key)
key - the property namepublic final PArray optArray(java.lang.String key)
key - the property namepublic final boolean isArray(java.lang.String key)
PObjectkey - the property namepublic final PJsonObject optJSONObject(java.lang.String key)
key - the property namepublic final PJsonObject getJSONObject(java.lang.String key)
key - the property namepublic final PJsonArray getJSONArray(java.lang.String key)
key - the property namepublic final PJsonArray optJSONArray(java.lang.String key)
key - the property namepublic final PJsonArray optJSONArray(java.lang.String key, PJsonArray defaultValue)
key - the property namedefaultValue - defaultpublic final java.util.Iterator<java.lang.String> keys()
public final int size()
public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic final org.json.JSONObject getInternalObj()
public final boolean has(java.lang.String key)
key - key to check for.public final java.lang.String toString()
toString in class java.lang.Object