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
See Also:
JSON home< /a>

Field Summary
 
Fields inherited from class org.restlet.resource.Representation
UNKNOWN_SIZE
 
Constructor Summary
JsonRepresentation(JSONObject jsonObject)
          Constructor from a JSON object.
JsonRepresentation(java.util.Map<java.lang.Object,java.lang.Object> map)
          Constructor from a map object.
JsonRepresentation(java.lang.Object bean)
          Constructor from a bean using reflection to generate JSON names.
JsonRepresentation(Representation jsonRepresentation)
          Constructor.
JsonRepresentation(java.lang.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, release, setCharacterSet, setText, updateSize, write
 
Methods inherited from class org.restlet.resource.StreamRepresentation
getChannel, getReader, write, write
 
Methods inherited from class org.restlet.resource.Representation
checkDigest, checkDigest, computeDigest, createEmpty, exhaust, getAvailableSize, getDigest, getDownloadName, getExpirationDate, getModificationDate, getRange, getSize, getTag, isAvailable, isDownloadable, isTransient, setAvailable, setDigest, setDownloadable, setDownloadName, setExpirationDate, setModificationDate, setRange, setSize, setTag, setTransient
 
Methods inherited from class org.restlet.resource.Variant
getCharacterSet, getEncodings, getIdentifier, getLanguages, getMediaType, setEncodings, setIdentifier, setIdentifier, setLanguages, setMediaType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsonRepresentation

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

Parameters:
jsonObject - The JSON object.

JsonRepresentation

public JsonRepresentation(java.util.Map<java.lang.Object,java.lang.Object> map)
Constructor from a map object.

Parameters:
map - The map to convert to JSON.
See Also:
JSONObject.JSONObject(Map)

JsonRepresentation

public JsonRepresentation(java.lang.Object bean)
Constructor from a bean using reflection to generate JSON names.

Parameters:
bean - The bean to convert to JSON.
See Also:
JSONObject.JSONObject(Object)

JsonRepresentation

public JsonRepresentation(Representation jsonRepresentation)
                   throws java.io.IOException
Constructor.

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

JsonRepresentation

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

Parameters:
jsonString - The JSON string.
Method Detail

toJsonArray

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

Returns:
The converted JSON array.
Throws:
JSONException

toJsonObject

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

Returns:
The converted JSON object.
Throws:
JSONException


Copyright © 2005-2008 Noelios Technologies.