DefaultJsonGenerator (Groovy 5.0.7)

Package: groovy.json

## [Java] Class DefaultJsonGenerator

- groovy.json.DefaultJsonGenerator

- All Implemented Interfaces and Traits:
    JsonGenerator

      public class DefaultJsonGenerator
      extends Object
      implements JsonGenerator

  A JsonGenerator that can be configured with various JsonGenerator.Options. If the default options are sufficient consider using the static `JsonOutput.toJson` methods.

  See Also:
    JsonGenerator.Options#build()
  Since:
    2.5.0

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `protected static class` | `DefaultJsonGenerator.ClosureConverter` | A converter that handles converting a given type using a closure.

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `protected Set<Converter>` | `converters` |
    `protected String` | `dateFormat` |
    `protected Locale` | `dateLocale` |
    `protected boolean` | `disableUnicodeEscaping` |
    `protected boolean` | `excludeNulls` |
    `protected Set<String>` | `excludedFieldNames` |
    `protected Set<Class<?>>` | `excludedFieldTypes` |
    `protected TimeZone` | `timezone` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `protected DefaultJsonGenerator(Options options)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected Converter` | `findConverter(Class<?> type)` Finds a converter that can handle the given type.
    `` | `protected Map<?, ?>` | `getObjectProperties(Object object)`
    `` | `public boolean` | `isExcludingFieldsNamed(String name)` {@inheritDoc}
    `` | `public boolean` | `isExcludingValues(Object value)` {@inheritDoc}
    `` | `protected boolean` | `shouldExcludeType(Class<?> type)` Indicates whether the given type should be excluded from the generated output.
    `` | `public String` | `toJson(Object object)` {@inheritDoc}
    `` | `protected void` | `writeArray(Class<?> arrayClass, Object array, CharBuf buffer)` Serializes array and writes it into specified buffer.
    `` | `protected void` | `writeCharSequence(CharSequence seq, CharBuf buffer)` Serializes any char sequence and writes it into specified buffer.
    `` | `protected void` | `writeDate(Date date, CharBuf buffer)` Serializes date and writes it into specified buffer.
    `` | `protected void` | `writeIterator(Iterator<?> iterator, CharBuf buffer)` Serializes iterator and writes it into specified buffer.
    `` | `protected void` | `writeMap(Map<?, ?> map, CharBuf buffer)` Serializes map and writes it into specified buffer.
    `` | `protected void` | `writeMapEntry(String key, Object value, CharBuf buffer)` Serializes a map entry and writes it into specified buffer.
    `` | `protected void` | `writeNumber(Class<?> numberClass, Number value, CharBuf buffer)` Serializes Number value and writes it into specified buffer.
    `` | `protected void` | `writeObject(Object object, CharBuf buffer)`
    `` | `protected void` | `writeObject(String key, Object object, CharBuf buffer)` Serializes object and writes it into specified buffer.
    `` | `protected void` | `writeRaw(CharSequence seq, CharBuf buffer)` Serializes any char sequence and writes it into specified buffer without performing any manipulation of the given text.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### protected final Set<Converter> converters

    - #### protected final String dateFormat

    - #### protected final Locale dateLocale

    - #### protected final boolean disableUnicodeEscaping

    - #### protected final boolean excludeNulls

    - #### protected final Set<String> excludedFieldNames

    - #### protected final Set<Class<?>> excludedFieldTypes

    - #### protected final TimeZone timezone

  - ### Constructor Detail

    - #### protected DefaultJsonGenerator(Options options)

  - ### Method Detail

    - #### protected Converter findConverter(Class<?> type)

      Finds a converter that can handle the given type. The first converter that reports it can handle the type is returned, based on the order in which the converters were specified. A `null` value will be returned if no suitable converter can be found for the given type.

      Parameters:
        `type` - that this converter can handle
      Returns:
        first converter that can handle the given type; else `null` if no compatible converters are found for the given type.

    - #### protected Map<?, ?> getObjectProperties(Object object)

    - #### @Override
      public boolean isExcludingFieldsNamed(String name)

      {@inheritDoc}

    - #### @Override
      public boolean isExcludingValues(Object value)

      {@inheritDoc}

    - #### protected boolean shouldExcludeType(Class<?> type)

      Indicates whether the given type should be excluded from the generated output.

      Parameters:
        `type` - the type to check
      Returns:
        `true` if the given type should not be output, else `false`

    - #### @Override
      public String toJson(Object object)

      {@inheritDoc}

    - #### protected void writeArray(Class<?> arrayClass, Object array, CharBuf buffer)

      Serializes array and writes it into specified buffer.

    - #### protected void writeCharSequence(CharSequence seq, CharBuf buffer)

      Serializes any char sequence and writes it into specified buffer.

    - #### protected void writeDate(Date date, CharBuf buffer)

      Serializes date and writes it into specified buffer.

    - #### protected void writeIterator(Iterator<?> iterator, CharBuf buffer)

      Serializes iterator and writes it into specified buffer.

    - #### protected void writeMap(Map<?, ?> map, CharBuf buffer)

      Serializes map and writes it into specified buffer.

    - #### protected void writeMapEntry(String key, Object value, CharBuf buffer)

      Serializes a map entry and writes it into specified buffer.

    - #### protected void writeNumber(Class<?> numberClass, Number value, CharBuf buffer)

      Serializes Number value and writes it into specified buffer.

    - #### protected void writeObject(Object object, CharBuf buffer)

    - #### protected void writeObject(String key, Object object, CharBuf buffer)

      Serializes object and writes it into specified buffer.

    - #### protected void writeRaw(CharSequence seq, CharBuf buffer)

      Serializes any char sequence and writes it into specified buffer without performing any manipulation of the given text.