Package playn.core
Interface Json.Object
- Enclosing interface:
Json
public static interface Json.Object
Represents a parsed JSON object as a simple
string->value map.-
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(String key) Returns true if this object contains a value at the specified key, false if not.Gets the array value at the given key, ornullif there is no value at this key.<T> Json.TypedArray<T>Gets an array at the given key that assumes its values are of the given json type, ornullif there is no value at this key.<T> Json.TypedArray<T>getArray(String key, Class<T> jsonType, Json.TypedArray<T> dflt) Gets an array at the given key that assumes its values are of the given json type, or the default if there is no value at this key.getArray(String key, Json.Array dflt) Gets the array value at the given key, or the default if there is no value at this key.booleangetBoolean(String key) Gets the boolean value at the given key, orfalseif there is no value at this key.booleangetBoolean(String key, boolean dflt) Gets the boolean value at the given key, or the default if there is no value at this key.doubleGets the double value at the given key, or0if there is no value at this key.doubleGets the double value at the given key, or the default if there is no value at this key.intGets the integer value at the given key, or0if there is no value at this key.intGets the integer value at the given key, or the default if there is no value at this key.longGets the long value at the given key, or0if there is no value at this key.longGets the long value at the given key, or the default if there is no value at this key.floatGets the float value at the given key, or0if there is no value at this key.floatGets the float value at the given key, or the default if there is no value at this key.Gets the object value at the given key, ornullif there is no value at this key.getObject(String key, Json.Object dflt) Gets the object value at the given key, or the default if there is no value at this key.Gets the string value at the given key, ornullif there is no value at this key.Gets the string value at the given key, or the default if there is no value at this key.booleanReturnstrueif the value at the given key is an array.booleanReturnstrueif the value at the given key is a boolean.booleanReturnstrueif the value at the given key is null or does not exist.booleanReturnstrueif the value at the given key is a number.booleanReturnstrueif the value at the given key is an object.booleanReturnstrueif the value at the given key is a string.keys()Gets a snapshot of the current set of keys for this JSON object.Inserts a JSON null, object, array or string value at the given key.Removes a JSON value at the given key.<T extends playn.core.json.JsonSink<T>>
playn.core.json.JsonSink<T>write(playn.core.json.JsonSink<T> sink) Writes this object to aJsonSink.
-
Method Details
-
getBoolean
Gets the boolean value at the given key, orfalseif there is no value at this key. -
getBoolean
Gets the boolean value at the given key, or the default if there is no value at this key. -
getNumber
Gets the float value at the given key, or0if there is no value at this key. -
getNumber
Gets the float value at the given key, or the default if there is no value at this key. -
getDouble
Gets the double value at the given key, or0if there is no value at this key. -
getDouble
Gets the double value at the given key, or the default if there is no value at this key. -
getInt
Gets the integer value at the given key, or0if there is no value at this key. -
getInt
Gets the integer value at the given key, or the default if there is no value at this key. -
getLong
Gets the long value at the given key, or0if there is no value at this key. NOTE: this is not accurate on the HTML backend as all numbers are represented as doubles, which cannot represent all possible long values. This is included for projects that use only the other backends and need long values. -
getLong
Gets the long value at the given key, or the default if there is no value at this key. NOTE: this is not accurate on the HTML backend as all numbers are represented as doubles, which cannot represent all possible long values. This is included for projects that use only the other backends and need long values. -
getString
Gets the string value at the given key, ornullif there is no value at this key. -
getString
Gets the string value at the given key, or the default if there is no value at this key. -
getObject
Gets the object value at the given key, ornullif there is no value at this key. -
getObject
Gets the object value at the given key, or the default if there is no value at this key. -
getArray
Gets the array value at the given key, ornullif there is no value at this key. -
getArray
Gets the array value at the given key, or the default if there is no value at this key. -
getArray
Gets an array at the given key that assumes its values are of the given json type, ornullif there is no value at this key.- Parameters:
jsonType- one of Json.Object, Json.Array, Boolean, Integer, Float, Double, or String- Throws:
IllegalArgumentException- if jsonType is of an invalid type.
-
getArray
Gets an array at the given key that assumes its values are of the given json type, or the default if there is no value at this key.- Parameters:
jsonType- one of Json.Object, Json.Array, Boolean, Integer, Float, Double, or Stringdflt- An existing typed array- Throws:
IllegalArgumentException- if jsonType is of an invalid type.
-
containsKey
Returns true if this object contains a value at the specified key, false if not. -
keys
Json.TypedArray<String> keys()Gets a snapshot of the current set of keys for this JSON object. Modifications to the object will not be reflected in this set of keys. -
isArray
Returnstrueif the value at the given key is an array. -
isBoolean
Returnstrueif the value at the given key is a boolean. -
isNull
Returnstrueif the value at the given key is null or does not exist. -
isNumber
Returnstrueif the value at the given key is a number. -
isString
Returnstrueif the value at the given key is a string. -
isObject
Returnstrueif the value at the given key is an object. -
put
Inserts a JSON null, object, array or string value at the given key.- Returns:
- a reference to this, allowing the calls to be chained together.
-
remove
Removes a JSON value at the given key.- Returns:
- a reference to this, allowing the calls to be chained together.
-
write
<T extends playn.core.json.JsonSink<T>> playn.core.json.JsonSink<T> write(playn.core.json.JsonSink<T> sink) Writes this object to aJsonSink.
-