Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## grails.util
Class JSonBuilder

    java.lang.Object
      groovy.lang.GroovyObjectSupport
          groovy.util.BuilderSupport
              grails.util.JSonBuilder

All Implemented Interfaces:
  groovy.lang.GroovyObject

    public class JSonBuilder

extends groovy.util.BuilderSupport

JSonBuilder provides support for creating JSON responses

If this builder is used in controllers no views should be configured since content will be written to the HttpServletResponse instance. Also no operations should be performed on the response object prior to passing it to this builder.

This builder will set the content type of the response to "text/json"

Sending a simple key value pair to the client requires this code:

     new JsonBuilder(response).json{ message('Hello World') }

will produce output as follows:

    {"message":"Hello World"}

Since:
  0.2 Date Created: May, 18, 2006
Author:
  Michał Kłujszo, Graeme Rocher

Constructor Summary
`JSonBuilder(HttpServletResponse response)`
`JSonBuilder(JSONWriter _writer)`
`JSonBuilder(Writer writer)`

Method Summary
`protected Object` | `createNode(Object name)`
`protected Object` | `createNode(Object key, Map valueMap)`
`protected Object` | `createNode(Object arg0, Map arg1, Object arg2)`
`protected Object` | `createNode(Object key, Object value)`
`protected void` | `nodeCompleted(Object parent, Object node)`
`protected void` | `setParent(Object arg0, Object arg1)`

Methods inherited from class groovy.util.BuilderSupport
`doInvokeMethod, getCurrent, getName, invokeMethod, invokeMethod, postNodeCompletion, setClosureDelegate, setCurrent`

Methods inherited from class groovy.lang.GroovyObjectSupport
`getMetaClass, getProperty, setMetaClass, setProperty`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JSonBuilder

    public JSonBuilder(HttpServletResponse response)
                throws IOException

Throws:
  `IOException`

### JSonBuilder

    public JSonBuilder(JSONWriter _writer)

### JSonBuilder

    public JSonBuilder(Writer writer)

Method Detail

### createNode

    protected Object createNode(Object name)

  Specified by:
    `createNode` in class `groovy.util.BuilderSupport`

### createNode

    protected Object createNode(Object key,
                                Map valueMap)

  Specified by:
    `createNode` in class `groovy.util.BuilderSupport`

### createNode

    protected Object createNode(Object arg0,
                                Map arg1,
                                Object arg2)

  Specified by:
    `createNode` in class `groovy.util.BuilderSupport`

### createNode

    protected Object createNode(Object key,
                                Object value)

  Specified by:
    `createNode` in class `groovy.util.BuilderSupport`

### nodeCompleted

    protected void nodeCompleted(Object parent,
                                 Object node)

  Overrides:
    `nodeCompleted` in class `groovy.util.BuilderSupport`

### setParent

    protected void setParent(Object arg0,
                             Object arg1)

  Specified by:
    `setParent` in class `groovy.util.BuilderSupport`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2005-2006 The Grails project