public static class StreamingJsonBuilder.StreamingJsonDelegate extends GroovyObjectSupport
| Constructor and Description | 
|---|
StreamingJsonBuilder.StreamingJsonDelegate(Writer w,
                                          boolean first)  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
call(String name,
    Collection coll,
    Closure c)
A collection and closure passed to a JSON builder will create a root JSON array applying
 the closure to each object in the collection 
 | 
void | 
call(String name,
    JsonOutput.JsonUnescaped json)
Writes an unescaped value. 
 | 
void | 
call(String name,
    List<Object> list)
Writes the name and a JSON array 
 | 
void | 
call(String name,
    Object... array)
Writes the name and a JSON array 
 | 
void | 
call(String name,
    Object value)
Writes the name and value of a JSON attribute 
 | 
static void | 
cloneDelegateAndGetContent(Writer w,
                          Closure c)  | 
static void | 
cloneDelegateAndGetContent(Writer w,
                          Closure c,
                          boolean first)  | 
static void | 
curryDelegateAndGetContent(Writer w,
                          Closure c,
                          Object o)  | 
static void | 
curryDelegateAndGetContent(Writer w,
                          Closure c,
                          Object o,
                          boolean first)  | 
Object | 
invokeMethod(String name,
            Object args)
Invokes the given method. 
 | 
static boolean | 
isCollectionWithClosure(Object[] args)  | 
static Object | 
writeCollectionWithClosure(Writer writer,
                          Collection coll,
                          Closure closure)  | 
getMetaClass, getProperty, setMetaClass, setPropertypublic StreamingJsonBuilder.StreamingJsonDelegate(Writer w, boolean first)
public Object invokeMethod(String name, Object args)
GroovyObjectinvokeMethod in interface GroovyObjectinvokeMethod in class GroovyObjectSupportname - the name of the method to callargs - the arguments to use for the method callpublic void call(String name, List<Object> list) throws IOException
name - The name of the JSON attributelist - The list representing the arrayIOExceptionpublic void call(String name, Object... array) throws IOException
name - The name of the JSON attributearray - The list representing the arrayIOExceptionpublic void call(String name, Collection coll, Closure c) throws IOException
Example:
 class Author {
      String name
 }
 def authorList = [new Author (name: "Guillaume"), new Author (name: "Jochen"), new Author (name: "Paul")]
 new StringWriter().with { w ->
     def json = new groovy.json.StreamingJsonBuilder(w)
     json.book {
        authors authorList, { Author author ->
         name author.name
       }
     }
     assert w.toString() == '{"book":{"authors":[{"name":"Guillaume"},{"name":"Jochen"},{"name":"Paul"}]}}'
 }
 coll - a collectionc - a closure used to convert the objects of collIOExceptionpublic void call(String name, Object value) throws IOException
name - The attribute namevalue - The valueIOExceptionpublic void call(String name, JsonOutput.JsonUnescaped json) throws IOException
name - The attribute namejson - The valueIOExceptionpublic static boolean isCollectionWithClosure(Object[] args)
public static Object writeCollectionWithClosure(Writer writer, Collection coll, Closure closure) throws IOException
IOExceptionpublic static void cloneDelegateAndGetContent(Writer w, Closure c, boolean first)
public static void curryDelegateAndGetContent(Writer w, Closure c, Object o)