## 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 is a map of string-based keys onto a set of `JSONValue` objects.

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 key.
`JSONValue` `get(java.lang.String key)` Gets the JSONValue associated with the specified key.
`JSONObject` `isObject()` Returns `this`, as this is a JSONObject.
`java.util.Set` `keySet()` Returns keys for which this JSONObject has associations.
`JSONValue` `put(java.lang.String key, JSONValue jsonValue)` Maps the specified key to the specified value in this JSONObject.
`int` `size()` Determines the number of keys 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, equals, finalize, getClass, hashCode, 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 key. We use Object.hasOwnProperty here to verify that a given key is specified on this object rather than a superclass (such as standard properties defined on Object).

  Parameters:
    `key` - the key to search for
  Returns:
    `true` if the JSONObject contains the specified key

### get

    public JSONValue get(java.lang.String key)

  Gets the JSONValue associated with the specified key. We use Object.hasOwnProperty here to verify that a given key is specified on this object rather than a superclass (such as standard properties defined on Object).

  Parameters:
    `key` - the key to search for
  Returns:
    if found, the value associated with the specified key, or `null` otherwise

### 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 keySet()

  Returns keys for which this JSONObject has associations.

  Returns:
    array of keys for which there is a value

### put

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

  Maps the specified key to the specified value in this JSONObject. If the specified key already has an associated value, it is overwritten.

  Parameters:
    `key` - the key to associate with the specified value
    `jsonValue` - the value to associate with this key
  Returns:
    if one existed, the previous value associated with the key, or `null` otherwise
  Throws:
    `java.lang.NullPointerException` - if key is `null`

### size

    public int size()

  Determines the number of keys 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