|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.codehaus.groovy.grails.web.converters.AbstractConverter<org.codehaus.groovy.grails.web.json.JSONWriter>
grails.converters.JSON
public class JSON
A converter that converts domain classes, Maps, Lists, Arrays, POJOs and POGOs to JSON.
| Nested Class Summary | |
|---|---|
class |
JSON.Builder
|
| Nested classes/interfaces inherited from interface org.codehaus.groovy.grails.web.converters.Converter |
|---|
Converter.CircularReferenceBehaviour |
| Field Summary | |
|---|---|
protected java.util.Stack<java.lang.Object> |
referenceStack
|
protected org.codehaus.groovy.grails.web.json.JSONWriter |
writer
|
| Fields inherited from interface org.codehaus.groovy.grails.web.converters.Converter |
|---|
DEFAULT_REQUEST_ENCODING |
| Constructor Summary | |
|---|---|
JSON()
Default Constructor for a JSON Converter |
|
JSON(java.lang.Object target)
Creates a new JSON Converter for the given Object |
|
| Method Summary | |
|---|---|
void |
build(groovy.lang.Closure c)
|
void |
convertAnother(java.lang.Object o)
|
static void |
createNamedConfig(java.lang.String name,
groovy.lang.Closure<?> callable)
|
int |
getDepth()
|
static ConverterConfiguration<JSON> |
getNamedConfig(java.lang.String configName)
|
org.codehaus.groovy.grails.web.json.JSONWriter |
getWriter()
|
protected void |
handleCircularRelationship(java.lang.Object o)
|
protected ConverterConfiguration<JSON> |
initConfig()
|
ObjectMarshaller<JSON> |
lookupObjectMarshaller(java.lang.Object target)
|
static java.lang.Object |
parse(javax.servlet.http.HttpServletRequest request)
Parses the given request's InputStream and returns ether a JSONObject or a JSONArry |
static org.codehaus.groovy.grails.web.json.JSONElement |
parse(java.io.InputStream is,
java.lang.String encoding)
Parses the given JSON and returns ether a JSONObject or a JSONArry |
static org.codehaus.groovy.grails.web.json.JSONElement |
parse(java.io.Reader reader)
Parses the given JSON String and returns ether a JSONObject or a JSONArry |
static org.codehaus.groovy.grails.web.json.JSONElement |
parse(java.lang.String source)
Parses the given JSON String and returns ether a JSONObject or a JSONArry |
void |
property(java.lang.String key,
java.lang.Object value)
|
static void |
registerObjectMarshaller(java.lang.Class<?> clazz,
groovy.lang.Closure<?> callable)
|
static void |
registerObjectMarshaller(java.lang.Class<?> clazz,
int priority,
groovy.lang.Closure<?> callable)
|
static void |
registerObjectMarshaller(ObjectMarshaller<JSON> om)
|
static void |
registerObjectMarshaller(ObjectMarshaller<JSON> om,
int priority)
|
void |
render(javax.servlet.http.HttpServletResponse response)
Directs the JSON Writer to the Outputstream of the HttpServletResponse and sets the Content-Type to application/json |
void |
render(java.io.Writer out)
Directs the JSON Writer to the given Writer |
void |
setPrettyPrint(boolean prettyPrint)
|
void |
setTarget(java.lang.Object target)
Sets the Object which is later converted to JSON |
java.lang.String |
toString(boolean prettyPrint)
Performs the conversion and returns the resulting JSON as String |
static void |
use(java.lang.String cfgName)
|
static java.lang.Object |
use(java.lang.String configName,
groovy.lang.Closure<?> callable)
|
void |
value(java.lang.Object o)
|
static void |
withDefaultConfiguration(groovy.lang.Closure<?> callable)
|
| Methods inherited from class org.codehaus.groovy.grails.web.converters.AbstractConverter |
|---|
createBeanWrapper, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected org.codehaus.groovy.grails.web.json.JSONWriter writer
protected java.util.Stack<java.lang.Object> referenceStack
| Constructor Detail |
|---|
public JSON()
public JSON(java.lang.Object target)
target - the Object to convert| Method Detail |
|---|
protected ConverterConfiguration<JSON> initConfig()
public void setPrettyPrint(boolean prettyPrint)
public void render(java.io.Writer out)
throws ConverterException
out - the Writer
ConverterException
public void render(javax.servlet.http.HttpServletResponse response)
throws ConverterException
response - a HttpServletResponse
ConverterException
public org.codehaus.groovy.grails.web.json.JSONWriter getWriter()
throws ConverterException
ConverterException
public void convertAnother(java.lang.Object o)
throws ConverterException
ConverterException
public void build(groovy.lang.Closure c)
throws ConverterException
ConverterException
public void value(java.lang.Object o)
throws ConverterException
o -
ConverterExceptionpublic ObjectMarshaller<JSON> lookupObjectMarshaller(java.lang.Object target)
public int getDepth()
public void property(java.lang.String key,
java.lang.Object value)
throws org.codehaus.groovy.grails.web.json.JSONException,
ConverterException
org.codehaus.groovy.grails.web.json.JSONException
ConverterException
public java.lang.String toString(boolean prettyPrint)
throws org.codehaus.groovy.grails.web.json.JSONException
prettyPrint - true, if the output should be indented, otherwise false
org.codehaus.groovy.grails.web.json.JSONException
public static org.codehaus.groovy.grails.web.json.JSONElement parse(java.io.Reader reader)
throws ConverterException
reader - JSON source
ConverterException - when the JSON content is not valid
public static org.codehaus.groovy.grails.web.json.JSONElement parse(java.lang.String source)
throws ConverterException
source - A string containing some JSON
ConverterException - when the JSON content is not valid
public static org.codehaus.groovy.grails.web.json.JSONElement parse(java.io.InputStream is,
java.lang.String encoding)
throws ConverterException
is - An InputStream which delivers some JSONencoding - the Character Encoding to use
ConverterException - when the JSON content is not valid
public static java.lang.Object parse(javax.servlet.http.HttpServletRequest request)
throws ConverterException
request - the JSON Request
ConverterException - when the JSON content is not validpublic void setTarget(java.lang.Object target)
setTarget in class AbstractConverter<org.codehaus.groovy.grails.web.json.JSONWriter>target - the ObjectConverter
protected void handleCircularRelationship(java.lang.Object o)
throws ConverterException
ConverterException
public static ConverterConfiguration<JSON> getNamedConfig(java.lang.String configName)
throws ConverterException
ConverterException
public static java.lang.Object use(java.lang.String configName,
groovy.lang.Closure<?> callable)
throws ConverterException
ConverterException
public static void use(java.lang.String cfgName)
throws ConverterException
ConverterException
public static void registerObjectMarshaller(java.lang.Class<?> clazz,
groovy.lang.Closure<?> callable)
throws ConverterException
ConverterException
public static void registerObjectMarshaller(java.lang.Class<?> clazz,
int priority,
groovy.lang.Closure<?> callable)
throws ConverterException
ConverterException
public static void registerObjectMarshaller(ObjectMarshaller<JSON> om)
throws ConverterException
ConverterException
public static void registerObjectMarshaller(ObjectMarshaller<JSON> om,
int priority)
throws ConverterException
ConverterException
public static void createNamedConfig(java.lang.String name,
groovy.lang.Closure<?> callable)
throws ConverterException
ConverterException
public static void withDefaultConfiguration(groovy.lang.Closure<?> callable)
throws ConverterException
ConverterException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||