Package com.google.gwt.json.client
Class JSONObject
java.lang.Object
com.google.gwt.json.client.JSONValue
com.google.gwt.json.client.JSONObject
Represents a JSON object. A JSON object consists of a set of properties.
-
Constructor Summary
ConstructorDescriptionJSONObject
(JavaScriptObject jsValue) Creates a new JSONObject from the supplied JavaScript value. -
Method Summary
Modifier and TypeMethodDescriptionboolean
containsKey
(String key) Tests whether or not this JSONObject contains the specified property.boolean
Gets the JSONValue associated with the specified property.Returns the underlying JavaScript object that this object wraps.(package private) JavaScriptObject
Internal.int
hashCode()
isObject()
Returnsthis
, as this is a JSONObject.keySet()
Returns the set of properties defined on this JSONObject.Assign the specified property to the specified value in this JSONObject.int
size()
Determines the number of properties on this object.toString()
Converts a JSONObject into a JSON representation that can be used to communicate with a JSON service.
-
Constructor Details
-
JSONObject
public JSONObject() -
JSONObject
Creates a new JSONObject from the supplied JavaScript value.
-
-
Method Details
-
containsKey
Tests whether or not this JSONObject contains the specified property.- Parameters:
key
- the property to search for- Returns:
true
if the JSONObject contains the specified property
-
equals
-
get
Gets the JSONValue associated with the specified property.- Parameters:
key
- the property to access- Returns:
- the value of the specified property, or
null
if the property does not exist - Throws:
NullPointerException
- if key isnull
-
getJavaScriptObject
Returns the underlying JavaScript object that this object wraps. -
hashCode
public int hashCode() -
isObject
Returnsthis
, as this is a JSONObject. -
keySet
Returns the set of properties defined on this JSONObject. The returned set is immutable. -
put
Assign the specified property to the specified value in this JSONObject. If the property already has an associated value, it is overwritten.- Parameters:
key
- the property to assignjsonValue
- the value to assign- Returns:
- the previous value of the property, or
null
if the property did not exist - Throws:
NullPointerException
- if key isnull
-
size
public int size()Determines the number of properties on this object. -
toString
Converts a JSONObject into a JSON representation that can be used to communicate with a JSON service. -
getUnwrapper
JavaScriptObject getUnwrapper()Description copied from class:JSONValue
Internal. Returns a JS func that can unwrap this value. Used from native code.- Specified by:
getUnwrapper
in classJSONValue
-