Package: groovy.json

## [Java] Class StreamingJsonBuilder.StreamingJsonDelegate

- groovy.json.StreamingJsonBuilder.StreamingJsonDelegate

- The delegate used when invoking closures

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected boolean` | `first` |
    `protected StreamingJsonBuilder.StreamingJsonDelegate.State` | `state` |
    `protected Writer` | `writer` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `StreamingJsonDelegate (Writer w, boolean first)`
    `StreamingJsonDelegate (Writer w, boolean first, JsonGenerator generator)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `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, Iterable 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, Collection coll, Closure c)` Delegates to call(String, Iterable, Closure)
    `` | `void` | `call(String name, Object value)` Writes the name and value of a JSON attribute
    `` | `void` | `call(String name, Object value, Closure callable)` Writes the name and value of a JSON attribute
    `` | `void` | `call(String name, Closure value)` Writes the name and another JSON object
    `` | `void` | `call(String name, JsonUnescaped json)` Writes an unescaped value.
    `` | `void` | `call(String name, Writable json)` Writes the given Writable as the value of the given attribute name
    `` | `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)`
    `` | `Writer` | `getWriter()` Returns: Obtains the current writer
    `` | `Object` | `invokeMethod(String name, Object args)`
    `` | `static boolean` | `isCollectionWithClosure(Object[] args)`
    `` | `protected void` | `verifyValue()`
    `` | `protected void` | `writeArray(List<Object> list)`
    `` | `static Object` | `writeCollectionWithClosure(Writer writer, Collection coll, Closure closure)`
    `` | `protected void` | `writeName(String name)`
    `` | `protected void` | `writeValue(Object value)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class GroovyObjectSupport` | `getMetaClass, setMetaClass`

- - ### Field Detail

    - #### protected boolean first

    - #### protected StreamingJsonBuilder.StreamingJsonDelegate.State state

    - #### protected final Writer writer

  - ### Constructor Detail

    - #### public StreamingJsonDelegate(Writer w, boolean first)

    - #### public StreamingJsonDelegate(Writer w, boolean first, JsonGenerator generator)

  - ### Method Detail

    - #### public void call(String name, List<Object> list)

      Writes the name and a JSON array

      throws:
        IOException
      Parameters:
        `name` - The name of the JSON attribute
        `list` - The list representing the array

    - #### public void call(String name, Object array)

      Writes the name and a JSON array

      throws:
        IOException
      Parameters:
        `name` - The name of the JSON attribute
        `array` - The list representing the array

    - #### public void call(String name, Iterable coll, @com.github.javaparser.ast.expr.SingleMemberAnnotationExprDelegatesTo 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

      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"}]}}'
           }

      Parameters:
        `coll` - a collection
        `c` - a closure used to convert the objects of coll

    - #### public void call(String name, Collection coll, @com.github.javaparser.ast.expr.SingleMemberAnnotationExprDelegatesTo Closure c)

      Delegates to call(String, Iterable, Closure)

    - #### public void call(String name, Object value)

      Writes the name and value of a JSON attribute

      throws:
        IOException
      Parameters:
        `name` - The attribute name
        `value` - The value

    - #### public void call(String name, Object value, @com.github.javaparser.ast.expr.SingleMemberAnnotationExprDelegatesTo Closure callable)

      Writes the name and value of a JSON attribute

      throws:
        IOException
      Parameters:
        `name` - The attribute name
        `value` - The value

    - #### public void call(String name, @com.github.javaparser.ast.expr.SingleMemberAnnotationExprDelegatesTo Closure value)

      Writes the name and another JSON object

      throws:
        IOException
      Parameters:
        `name` - The attribute name
        `value` - The value

    - #### public void call(String name, JsonUnescaped json)

      Writes an unescaped value. Note: can cause invalid JSON if passed JSON is invalid

      throws:
        IOException
      Parameters:
        `name` - The attribute name
        `json` - The value

    - #### public void call(String name, Writable json)

      Writes the given Writable as the value of the given attribute name

      throws:
        IOException
      Parameters:
        `name` - The attribute name
        `json` - The writable value

    - #### public static void cloneDelegateAndGetContent(Writer w, @com.github.javaparser.ast.expr.SingleMemberAnnotationExprDelegatesTo Closure c)

    - #### public static void cloneDelegateAndGetContent(Writer w, @com.github.javaparser.ast.expr.SingleMemberAnnotationExprDelegatesTo Closure c, boolean first)

    - #### public static void curryDelegateAndGetContent(Writer w, @com.github.javaparser.ast.expr.SingleMemberAnnotationExprDelegatesTo Closure c, Object o)

    - #### public static void curryDelegateAndGetContent(Writer w, @com.github.javaparser.ast.expr.SingleMemberAnnotationExprDelegatesTo Closure c, Object o, boolean first)

    - #### public Writer getWriter()

      Returns:
        Obtains the current writer

    - #### public Object invokeMethod(String name, Object args)

    - #### public static boolean isCollectionWithClosure(Object[] args)

    - #### protected void verifyValue()

    - #### protected void writeArray(List<Object> list)

    - #### public static Object writeCollectionWithClosure(Writer writer, Collection coll, @com.github.javaparser.ast.expr.SingleMemberAnnotationExprDelegatesTo Closure closure)

    - #### protected void writeName(String name)

    - #### protected void writeValue(Object value)