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 x )
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. Order is not important.
getJSONArray( String key ) returns javaxt.json.JSONArray
Returns the JSONArray associated with a key.
getJSONObject( String key ) returns javaxt.json.JSONObject
Returns the JSONObject associated with a key.
getValue( String key ) returns javaxt.utils.Value
Returns the value associated with a key.
has( String key ) returns boolean
Returns true if the key exists 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.
setValue( String key, Boolean value ) returns void
Used to set the value for a given key with a boolean.
setValue( String key, Double value ) returns void
Used to set the value for a given key with a double.
setValue( String key, Float value ) returns void
Used to set the value for a given key with a float.
setValue( String key, Integer value ) returns void
Used to set the value for a given key with an integer.
setValue( String key, Long value ) returns void
Used to set the value for a given key with a long.
setValue( String key, String str ) returns void
Used to set the value for a given key with a String.
setValue( String key, javaxt.json.JSONObject json ) returns void
Used to set the value for a given key with a JSONObject.
setValue( String key, javaxt.json.JSONArray arr ) returns void
Used to set the value for a given key with a JSONArray.
setValue( String key, javaxt.utils.Value val ) returns void
Used to set the value for a given key with a javaxt.utils.Value.
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.