|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.representation.Variant
org.restlet.representation.RepresentationInfo
org.restlet.representation.Representation
org.restlet.representation.CharacterRepresentation
org.restlet.representation.WriterRepresentation
org.restlet.ext.json.JsonRepresentation
public class JsonRepresentation
Representation based on a JSON document. JSON stands for JavaScript Object Notation and is a lightweight data-interchange format.
Field Summary |
---|
Fields inherited from class org.restlet.representation.Representation |
---|
UNKNOWN_SIZE |
Constructor Summary | |
---|---|
JsonRepresentation(JSONArray jsonArray)
Constructor from a JSON array. |
|
JsonRepresentation(JSONObject jsonObject)
Constructor from a JSON object. |
|
JsonRepresentation(JSONStringer jsonStringer)
Constructor from a JSON stringer. |
|
JsonRepresentation(JSONTokener jsonTokener)
Constructor from a JSON tokener. |
|
JsonRepresentation(Map<String,Object> map)
Constructor from a map object. |
|
JsonRepresentation(Object bean)
Constructor from a bean using reflection to generate JSON names. |
|
JsonRepresentation(Representation jsonRepresentation)
Constructor. |
|
JsonRepresentation(String jsonString)
Constructor from a JSON string. |
Method Summary | |
---|---|
int |
getIndentingSize()
Returns the number of spaces to use for indentation. |
JSONArray |
getJsonArray()
Gets the wrapped JSON array or converts the wrapped representation if needed. |
JSONObject |
getJsonObject()
Gets the wrapped JSON object or converts the wrapped representation if needed. |
JSONTokener |
getJsonTokener()
Gets the wrapped JSON tokener or converts the wrapped representation if needed. |
long |
getSize()
|
boolean |
isIndenting()
Indicates if JSON objects and arrays should be indented. |
void |
setIndenting(boolean indenting)
Indicates if JSON objects and arrays should be indented. |
void |
setIndentingSize(int indentFactor)
Sets the number of spaces to use for indentation. |
JSONTokener |
toJsonTokener()
Deprecated. Use getJsonTokener() instead. |
void |
write(Writer writer)
|
Methods inherited from class org.restlet.representation.WriterRepresentation |
---|
getReader |
Methods inherited from class org.restlet.representation.CharacterRepresentation |
---|
getChannel, getStream, write, write |
Methods inherited from class org.restlet.representation.Representation |
---|
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, release, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient |
Methods inherited from class org.restlet.representation.RepresentationInfo |
---|
getModificationDate, getTag, setModificationDate, setTag |
Methods inherited from class org.restlet.representation.Variant |
---|
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JsonRepresentation(JSONArray jsonArray)
jsonArray
- The JSON array.public JsonRepresentation(JSONObject jsonObject)
jsonObject
- The JSON object.public JsonRepresentation(JSONStringer jsonStringer)
jsonStringer
- The JSON stringer.public JsonRepresentation(JSONTokener jsonTokener)
jsonTokener
- The JSON tokener.public JsonRepresentation(Map<String,Object> map)
map
- The map to convert to JSON.JSONObject.JSONObject(Map)
public JsonRepresentation(Object bean)
bean
- The bean to convert to JSON.JSONObject.JSONObject(Object)
public JsonRepresentation(Representation jsonRepresentation) throws IOException
jsonRepresentation
- A source JSON representation to parse.
IOException
public JsonRepresentation(String jsonString)
jsonString
- The JSON string.Method Detail |
---|
public int getIndentingSize()
public JSONArray getJsonArray() throws JSONException
JSONException
public JSONObject getJsonObject() throws JSONException
JSONException
public JSONTokener getJsonTokener() throws JSONException
JSONException
public long getSize()
getSize
in class Representation
public boolean isIndenting()
public void setIndenting(boolean indenting)
indenting
- True if JSON objects and arrays should be indented.public void setIndentingSize(int indentFactor)
indentFactor
- The number of spaces to use for indentation.@Deprecated public JSONTokener toJsonTokener() throws JSONException
getJsonTokener()
instead.
JSONException
public void write(Writer writer) throws IOException
write
in class Representation
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |