org.restlet.ext.json
Class JsonRepresentation

java.lang.Object
  extended by org.restlet.resource.Variant
      extended by org.restlet.resource.Representation
          extended by org.restlet.resource.StreamRepresentation
              extended by org.restlet.resource.StringRepresentation
                  extended by org.restlet.ext.json.JsonRepresentation

public class JsonRepresentation
extends StringRepresentation

Representation based on a JSON document. JSON stands for JavaScript Object Notation and is a lightweight data-interchange format.

Author:
Jerome Louvel (contact@noelios.com)
See Also:
JSON home

Field Summary
 
Fields inherited from class org.restlet.resource.Variant
UNKNOWN_SIZE
 
Constructor Summary
JsonRepresentation(JSONArray jsonArray)
          Constructor from a JSON array.
JsonRepresentation(JSONObject jsonObject)
          Constructor from a JSON object.
JsonRepresentation(Representation jsonRepresentation)
          Constructor.
JsonRepresentation(String jsonString)
          Constructor from a JSON string.
 
Method Summary
 JSONArray toJsonArray()
          Converts the representation to a JSON array.
 JSONObject toJsonObject()
          Converts the representation to a JSON object.
 
Methods inherited from class org.restlet.resource.StringRepresentation
getStream, getText, setText, updateSize, write
 
Methods inherited from class org.restlet.resource.StreamRepresentation
getChannel, write
 
Methods inherited from class org.restlet.resource.Representation
isAvailable, isTransient, setAvailable, setTransient
 
Methods inherited from class org.restlet.resource.Variant
getCharacterSet, getEncodings, getExpirationDate, getIdentifier, getLanguages, getMediaType, getModificationDate, getSize, getTag, setCharacterSet, setExpirationDate, setIdentifier, setIdentifier, setMediaType, setModificationDate, setSize, setTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonRepresentation

public JsonRepresentation(Representation jsonRepresentation)
                   throws IOException
Constructor.

Parameters:
jsonRepresentation - A source JSON representation to parse.
Throws:
IOException

JsonRepresentation

public JsonRepresentation(JSONObject jsonObject)
Constructor from a JSON object.

Parameters:
jsonObject - The JSON object.

JsonRepresentation

public JsonRepresentation(JSONArray jsonArray)
Constructor from a JSON array.

Parameters:
jsonArray - The JSON array.

JsonRepresentation

public JsonRepresentation(String jsonString)
Constructor from a JSON string.

Parameters:
jsonString - The JSON string.
Method Detail

toJsonObject

public JSONObject toJsonObject()
                        throws JSONException
Converts the representation to a JSON object.

Returns:
The converted JSON object.
Throws:
JSONException

toJsonArray

public JSONArray toJsonArray()
                      throws JSONException
Converts the representation to a JSON array.

Returns:
The converted JSON array.
Throws:
JSONException


Copyright © 2005-2007 Noelios Consulting.