elemental.json.impl.
Class JreJsonObject
- java.lang.Object
-
- elemental.json.impl.JreJsonValue
-
- elemental.json.impl.JreJsonObject
-
All Implemented Interfaces:
public class JreJsonObject extends JreJsonValue implements JsonObject
Server-side implementation of JsonObject.
See Also:
-
-
Constructor Summary
Constructors Constructor Description JreJsonObject(JsonFactory factory)
-
Method Summary
All Methods Modifier and Type Method Description boolean
asBoolean()
Coerces underlying value to boolean according to the rules of Javascript coercion.
double
asNumber()
Coerces the underlying value to a number according to the rules of Javascript coercion.
String
asString()
Coerces the underlying value to a String according to the rules of JavaScript coercion.
JsonValue
get(String key)
Return the element (uncoerced) as a JsonValue.
JsonArray
getArray(String key)
Return the element (uncoerced) as a JsonArray.
boolean
getBoolean(String key)
Return the element (uncoerced) as a boolean.
double
getNumber(String key)
Return the element (uncoerced) as a number.
Object
getObject()
JsonObject
getObject(String key)
Return the element (uncoerced) as a JsonObject If the type is not an object,, this can result in runtime errors.
String
getString(String key)
Return the element (uncoerced) as a String.
JsonType
getType()
Returns an enumeration representing the fundamental JSON type.
boolean
hasKey(String key)
Test whether a given key has present.
boolean
jsEquals(JsonValue value)
Equivalent of Javascript '==' operator comparison between two values.
String[]
keys()
All keys of the object.
void
put(String key, boolean bool)
Set a given key to the given boolean value.
void
put(String key, double value)
Set a given key to the given double value.
void
put(String key, JsonValue value)
Set a given key to the given value.
void
put(String key, String value)
Set a given key to the given String value.
void
remove(String key)
Remove a given key and associated value from the object.
void
set(String key, JsonValue value)
String
toJson()
Returns a serialized JSON string representing this value.
String
toString()
void
traverse(elemental.json.impl.JsonVisitor visitor, elemental.json.impl.JsonContext ctx)
-
Methods inherited from class elemental.json.impl.JreJsonValue
parseJson, toNative
-
-
-
-
Constructor Detail
-
JreJsonObject
public JreJsonObject(JsonFactory factory)
-
-
Method Detail
-
asBoolean
public boolean asBoolean()
Description copied from interface:
JsonValue
Coerces underlying value to boolean according to the rules of Javascript coercion.
-
asNumber
public double asNumber()
Description copied from interface:
JsonValue
Coerces the underlying value to a number according to the rules of Javascript coercion.
-
asString
public String asString()
Description copied from interface:
JsonValue
Coerces the underlying value to a String according to the rules of JavaScript coercion.
-
get
public JsonValue get(String key)
Description copied from interface:
JsonObject
Return the element (uncoerced) as a JsonValue.
Specified by:
get
in interfaceJsonObject
-
getArray
public JsonArray getArray(String key)
Description copied from interface:
JsonObject
Return the element (uncoerced) as a JsonArray. If the type is not an array, this can result in runtime errors.
Specified by:
getArray
in interfaceJsonObject
-
getBoolean
public boolean getBoolean(String key)
Description copied from interface:
JsonObject
Return the element (uncoerced) as a boolean. If the type is not a boolean, this can result in runtime errors.
Specified by:
getBoolean
in interfaceJsonObject
-
getNumber
public double getNumber(String key)
Description copied from interface:
JsonObject
Return the element (uncoerced) as a number. If the type is not a number, this can result in runtime errors.
Specified by:
getNumber
in interfaceJsonObject
-
getObject
public JsonObject getObject(String key)
Description copied from interface:
JsonObject
Return the element (uncoerced) as a JsonObject If the type is not an object,, this can result in runtime errors.
Specified by:
getObject
in interfaceJsonObject
-
getObject
public Object getObject()
Specified by:
getObject
in classJreJsonValue
-
getString
public String getString(String key)
Description copied from interface:
JsonObject
Return the element (uncoerced) as a String. If the type is not a String, this can result in runtime errors.
Specified by:
getString
in interfaceJsonObject
-
getType
public JsonType getType()
Description copied from interface:
JsonValue
Returns an enumeration representing the fundamental JSON type.
-
hasKey
public boolean hasKey(String key)
Description copied from interface:
JsonObject
Test whether a given key has present.
Specified by:
hasKey
in interfaceJsonObject
-
jsEquals
public boolean jsEquals(JsonValue value)
Description copied from interface:
JsonValue
Equivalent of Javascript '==' operator comparison between two values.
-
keys
public String[] keys()
Description copied from interface:
JsonObject
All keys of the object.
Specified by:
keys
in interfaceJsonObject
-
put
public void put(String key, JsonValue value)
Description copied from interface:
JsonObject
Set a given key to the given value.
Specified by:
put
in interfaceJsonObject
-
put
public void put(String key, String value)
Description copied from interface:
JsonObject
Set a given key to the given String value.
Specified by:
put
in interfaceJsonObject
-
put
public void put(String key, double value)
Description copied from interface:
JsonObject
Set a given key to the given double value.
Specified by:
put
in interfaceJsonObject
-
put
public void put(String key, boolean bool)
Description copied from interface:
JsonObject
Set a given key to the given boolean value.
Specified by:
put
in interfaceJsonObject
-
remove
public void remove(String key)
Description copied from interface:
JsonObject
Remove a given key and associated value from the object.
Specified by:
remove
in interfaceJsonObject
-
toJson
public String toJson()
Description copied from interface:
JsonValue
Returns a serialized JSON string representing this value.
-
traverse
public void traverse(elemental.json.impl.JsonVisitor visitor, elemental.json.impl.JsonContext ctx)
Specified by:
traverse
in classJreJsonValue
-
-