public class JsonRepresentation extends WriterRepresentation
UNKNOWN_SIZE
Constructor and Description |
---|
JsonRepresentation(org.json.JSONArray jsonArray)
Constructor from a JSON array.
|
JsonRepresentation(org.json.JSONObject jsonObject)
Constructor from a JSON object.
|
JsonRepresentation(org.json.JSONStringer jsonStringer)
Constructor from a JSON stringer.
|
JsonRepresentation(org.json.JSONTokener jsonTokener)
Constructor from a JSON tokener.
|
JsonRepresentation(java.util.Map<java.lang.String,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.
|
Modifier and Type | Method and Description |
---|---|
int |
getIndentingSize()
Returns the number of spaces to use for indentation.
|
org.json.JSONArray |
getJsonArray()
Gets the wrapped JSON array or converts the wrapped representation if
needed.
|
org.json.JSONObject |
getJsonObject()
Gets the wrapped JSON object or converts the wrapped representation if
needed.
|
org.json.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.
|
void |
write(java.io.Writer writer) |
getReader
getChannel, getStream, write, write
append, exhaust, getAvailableSize, getDigest, getDisposition, getExpirationDate, getRange, getRegistration, getText, hasKnownSize, isAvailable, isEmpty, isSelectable, isTransient, release, setAvailable, setDigest, setDisposition, setExpirationDate, setListener, setRange, setSize, setTransient
getModificationDate, getTag, setModificationDate, setTag
createClientInfo, equals, getCharacterSet, getEncodings, getLanguages, getLocationRef, getMediaType, hashCode, includes, isCompatible, setCharacterSet, setEncodings, setLanguages, setLocationRef, setLocationRef, setMediaType, toString
public JsonRepresentation(org.json.JSONArray jsonArray)
jsonArray
- The JSON array.public JsonRepresentation(org.json.JSONObject jsonObject)
jsonObject
- The JSON object.public JsonRepresentation(org.json.JSONStringer jsonStringer)
jsonStringer
- The JSON stringer.public JsonRepresentation(org.json.JSONTokener jsonTokener)
jsonTokener
- The JSON tokener.public JsonRepresentation(java.util.Map<java.lang.String,java.lang.Object> map)
map
- The map to convert to JSON.JSONObject(Map)
public JsonRepresentation(java.lang.Object bean)
bean
- The bean to convert to JSON.JSONObject(Object)
public JsonRepresentation(Representation jsonRepresentation) throws java.io.IOException
jsonRepresentation
- A source JSON representation to parse.java.io.IOException
public JsonRepresentation(java.lang.String jsonString)
jsonString
- The JSON string.public int getIndentingSize()
public org.json.JSONArray getJsonArray() throws org.json.JSONException
org.json.JSONException
public org.json.JSONObject getJsonObject() throws org.json.JSONException
org.json.JSONException
public org.json.JSONTokener getJsonTokener() throws org.json.JSONException
org.json.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.public void write(java.io.Writer writer) throws java.io.IOException
write
in class Representation
java.io.IOException
Copyright © 2005-2024 Restlet.