com.sdicons.json.model
Class JSONObject

java.lang.Object
  extended by com.sdicons.json.model.JSONValue
      extended by com.sdicons.json.model.JSONComplex
          extended by com.sdicons.json.model.JSONObject

public class JSONObject
extends JSONComplex

Representation of a JSON object, a collection (unordered) of name/value pairs. An example: {"name":"Homer", "age":40, "children":["Bart", "Maggie", "Lisa"]}


Constructor Summary
JSONObject()
           
 
Method Summary
 boolean containsKey(String aKey)
           
 boolean equals(Object o)
           
 JSONValue get(String aKey)
          Utility method, get the element with specified name without having to retreive the map first using getValue().
 HashMap<String,JSONValue> getValue()
           
 int hashCode()
           
protected  String render(boolean aPretty, String aIndent)
          Convert the JSON value into a string representation (JSON representation).
 int size()
           
 Object strip()
          Remove all JSON related information.
 String toString()
           
 
Methods inherited from class com.sdicons.json.model.JSONValue
decorate, getCol, getData, getLine, getStreamName, isArray, isBoolean, isComplex, isDecimal, isInteger, isNull, isNumber, isObject, isSimple, isString, render, setData, setLineCol, setStreamName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JSONObject

public JSONObject()
Method Detail

size

public int size()
Specified by:
size in class JSONComplex

getValue

public HashMap<String,JSONValue> getValue()

toString

public String toString()
Overrides:
toString in class Object

render

protected String render(boolean aPretty,
                        String aIndent)
Description copied from class: JSONValue
Convert the JSON value into a string representation (JSON representation).

Specified by:
render in class JSONValue
Parameters:
aPretty - Indicating if the print should be made pretty (human readers) or compact (transmission or storage).
aIndent - Starting indent.
Returns:
A JSON representation.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

containsKey

public boolean containsKey(String aKey)

get

public JSONValue get(String aKey)
Utility method, get the element with specified name without having to retreive the map first using getValue().

Parameters:
aKey - The key for which you want to retrieve the element.
Returns:
The element corresponding to the key or null if the object does not contain a key with this name.

strip

public Object strip()
Remove all JSON related information. In the case of a JSONObject, a HashMap is returned. The values of the HashMap are stripped as well.

Specified by:
strip in class JSONValue
Returns:
a HashMap, containing pure Java objects.


Copyright © 2011. All Rights Reserved.