|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.codehaus.groovy.grails.web.converters.AbstractConverter grails.converters.JSON
public class JSON extends AbstractConverter
A converter that converts domain classes, Maps, Lists, Arrays, POJOs and POGOs to JSON.
Nested Class Summary | |
---|---|
class |
JSON.Builder
|
Field Summary | |
---|---|
protected java.util.Stack |
referenceStack
|
protected JSONWriter |
writer
|
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
|
getNamedConfig(java.lang.String configName)
|
JSONWriter
|
getWriter()
|
protected void
|
handleCircularRelationship(java.lang.Object o)
|
protected ConverterConfiguration
|
initConfig()
|
ObjectMarshaller
|
lookupObjectMarshaller(java.lang.Object target)
|
static JSONElement
|
parse(java.io.Reader reader)
Parses the given JSON String and returns ether a JSONObject or a JSONArry |
static JSONElement
|
parse(java.lang.String source)
Parses the given JSON String and returns ether a JSONObject or a JSONArry |
static JSONElement
|
parse(java.io.InputStream is, java.lang.String encoding)
Parses the given JSON and returns ether a JSONObject or a JSONArry |
static java.lang.Object
|
parse(javax.servlet.http.HttpServletRequest request)
Parses the given request's InputStream 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 om)
|
static void
|
registerObjectMarshaller(ObjectMarshaller om, int priority)
|
void
|
render(java.io.Writer out)
Directs the JSON Writer to the given Writer |
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
|
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 java.lang.Object
|
use(java.lang.String configName, groovy.lang.Closure callable)
|
static void
|
use(java.lang.String cfgName)
|
void
|
value(java.lang.Object o)
@param o |
static void
|
withDefaultConfiguration(groovy.lang.Closure callable)
|
Methods inherited from class AbstractConverter | |
---|---|
createBeanWrapper, setTarget, toString |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
protected java.util.Stack referenceStack
protected JSONWriter writer
Constructor Detail |
---|
public JSON()
public JSON(java.lang.Object target)
target
- the Object to convert
Method Detail |
---|
public void build(@SuppressWarnings("rawtypes") groovy.lang.Closure c)
public void convertAnother(java.lang.Object o)
public static void createNamedConfig(java.lang.String name, groovy.lang.Closure callable)
public int getDepth()
public static ConverterConfiguration getNamedConfig(java.lang.String configName)
public JSONWriter getWriter()
protected void handleCircularRelationship(java.lang.Object o)
protected ConverterConfiguration initConfig()
public ObjectMarshaller lookupObjectMarshaller(@SuppressWarnings("hiding") java.lang.Object target)
public static JSONElement parse(java.io.Reader reader)
reader
- JSON source
public static JSONElement parse(java.lang.String source)
source
- A string containing some JSON
public static JSONElement parse(java.io.InputStream is, java.lang.String encoding)
is
- An InputStream which delivers some JSONencoding
- the Character Encoding to use
public static java.lang.Object parse(javax.servlet.http.HttpServletRequest request)
request
- the JSON Request
public void property(java.lang.String key, java.lang.Object value)
public static void registerObjectMarshaller(java.lang.Class clazz, groovy.lang.Closure callable)
public static void registerObjectMarshaller(java.lang.Class clazz, int priority, groovy.lang.Closure callable)
public static void registerObjectMarshaller(ObjectMarshaller om)
public static void registerObjectMarshaller(ObjectMarshaller om, int priority)
public void render(java.io.Writer out)
out
- the Writer
public void render(javax.servlet.http.HttpServletResponse response)
response
- a HttpServletResponse
public void setPrettyPrint(boolean prettyPrint)
} public void setTarget(java.lang.Object target)
target
- the Object
public java.lang.String toString(@SuppressWarnings("hiding") boolean prettyPrint)
prettyPrint
- true, if the output should be indented, otherwise false
public static java.lang.Object use(java.lang.String configName, groovy.lang.Closure callable)
public static void use(java.lang.String cfgName)
public void value(java.lang.Object o)
public static void withDefaultConfiguration(groovy.lang.Closure callable)
Groovy Documentation