Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gwt.json.client
Class JSONObject

    java.lang.Object
      com.google.gwt.json.client.JSONValue
          com.google.gwt.json.client.JSONObject

    public class JSONObject

extends JSONValue

Represents a JSON object. A JSON object consists of a set of properties.

Constructor Summary
`JSONObject()`
`JSONObject(JavaScriptObject jsValue)` Creates a new JSONObject from the supplied JavaScript value.

Method Summary
`boolean` | `containsKey(java.lang.String key)` Tests whether or not this JSONObject contains the specified property.
`boolean` | `equals(java.lang.Object other)` Returns `true` if `other` is a `JSONObject` wrapping the same underlying object.
`JSONValue` | `get(java.lang.String key)` Gets the JSONValue associated with the specified property.
`JavaScriptObject` | `getJavaScriptObject()` Returns the underlying JavaScript object that this object wraps.
`int` | `hashCode()`
`JSONObject` | `isObject()` Returns `this`, as this is a JSONObject.
`java.util.Set<java.lang.String>` | `keySet()` Returns the set of properties defined on this JSONObject.
`JSONValue` | `put(java.lang.String key, JSONValue jsonValue)` Assign the specified property to the specified value in this JSONObject.
`int` | `size()` Determines the number of properties on this object.
`java.lang.String` | `toString()` Converts a JSONObject into a JSON representation that can be used to communicate with a JSON service.

Methods inherited from class com.google.gwt.json.client.JSONValue
`isArray, isBoolean, isNull, isNumber, isString`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

Constructor Detail

### JSONObject

    public JSONObject()

### JSONObject

    public JSONObject(JavaScriptObject jsValue)

  Creates a new JSONObject from the supplied JavaScript value.

Method Detail

### containsKey

    public boolean containsKey(java.lang.String key)

  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

    public boolean equals(java.lang.Object other)

  Returns `true` if `other` is a `JSONObject` wrapping the same underlying object.

  Overrides:
    `equals` in class `java.lang.Object`

### get

    public JSONValue get(java.lang.String key)

  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:
    `java.lang.NullPointerException` - if key is `null`

### getJavaScriptObject

    public JavaScriptObject getJavaScriptObject()

  Returns the underlying JavaScript object that this object wraps.

### hashCode

    public int hashCode()

  Overrides:
    `hashCode` in class `java.lang.Object`

### isObject

    public JSONObject isObject()

  Returns `this`, as this is a JSONObject.

  Overrides:
    `isObject` in class `JSONValue`
  Returns:
    a reference to a JSONObject if this JSONValue is a JSONObject or `null` otherwise.

### keySet

    public java.util.Set<java.lang.String> keySet()

  Returns the set of properties defined on this JSONObject.

### put

    public JSONValue put(java.lang.String key,
                         JSONValue jsonValue)

  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 assign
    `jsonValue` - the value to assign
  Returns:
    the previous value of the property, or `null` if the property did not exist
  Throws:
    `java.lang.NullPointerException` - if key is `null`

### size

    public int size()

  Determines the number of properties on this object.

### toString

    public java.lang.String toString()

  Converts a JSONObject into a JSON representation that can be used to communicate with a JSON service.

  Specified by:
    `toString` in class `JSONValue`
  Returns:
    a JSON string representation of this JSONObject instance

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD