JSONObject Class

Used to create and parse JSON documents. JSON documents are an unordered collection of name/value pairs. Its external form is a string wrapped in curly braces with colons between the names and values, and commas between the values and names.

Constructors

public JSONObject( )
public JSONObject( String source )
protected JSONObject( javaxt.json.JSONTokener source )
public JSONObject( org.w3c.dom.Document xml )
public JSONObject( org.w3c.dom.Node node )

Methods

equals( Object obj ) returns boolean
Returns true if the given object is a JSONObject and the JSONObject contains the same key/value pairs. The comparison is made by cloning the two JSONObjects using the toString() method. Example: JSONObject j1 = new JSONObject(this.toString()); Note that the order of the key/value pairs is not important.
get( String key ) returns javaxt.json.JSONValue
Returns the value associated with a key.
has( String key ) returns boolean
Returns true if the key exists in the JSONObject.
isEmpty( ) returns boolean
Returns true if there are no entries in the JSONObject.
isNull( String key ) returns boolean
Returns true if there is no value associated with the key.
keys( ) returns java.util.Iterator
Returns an enumeration of the keys of the JSONObject. Modifying this key Set will also modify the JSONObject. Use with caution.
keySet( ) returns java.util.Set
Returns a set of keys of the JSONObject. Modifying this key Set will also modify the JSONObject. Use with caution.
length( ) returns int
Returns the number of keys in the JSONObject.
remove( String key ) returns Object
Remove a name and its value, if present. Returns the value that was associated with the name, or null if there was no value.
set( String key, Object value ) returns void
Used to set the value for a given key.
toString( ) returns String
Returns the JSONObject as a String. For compactness, no whitespace is added. If this would not result in a syntactically correct JSON text, then null will be returned instead.
toString( int indentFactor ) returns String
Returns a pretty-printed JSON text of this JSONObject.
indentFactorThe number of spaces to add to each level of indentation.