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.
| Modifiers | Name | Description |
|---|---|---|
protected static class |
DefaultJsonGenerator.ClosureConverter |
A converter that handles converting a given type using a closure. |
| Modifiers | Name | Description |
|---|---|---|
protected Set<Converter> |
converters |
Converters consulted before applying the default JSON serialization rules. |
protected String |
dateFormat |
Date format pattern used when serializing Date values. |
protected Locale |
dateLocale |
Locale used when formatting Date values. |
protected boolean |
disableUnicodeEscaping |
Indicates whether Unicode characters are emitted without escaping. |
protected boolean |
excludeNulls |
Indicates whether null values are omitted from the output. |
protected Set<String> |
excludedFieldNames |
Field names excluded from generated JSON objects. |
protected Set<Class<?>> |
excludedFieldTypes |
Field types excluded from generated JSON objects. |
protected TimeZone |
timezone |
Time zone used when formatting Date values. |
| Constructor and description |
|---|
protected DefaultJsonGenerator(Options options)Creates a generator from the supplied serialization options. |
| 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)Collects the public readable properties of the given object for JSON object serialization. |
|
public boolean |
isExcludingFieldsNamed(String name)Indicates whether this JsonGenerator is configured to exclude fields by the given name.
|
|
public boolean |
isExcludingValues(Object value)Indicates whether this JsonGenerator is configured to exclude values of the given object (may be null).
|
|
protected boolean |
shouldExcludeType(Class<?> type)Indicates whether the given type should be excluded from the generated output. |
|
public String |
toJson(Object object)Converts an object to its JSON representation.
|
|
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)Serializes an unnamed value and writes it into the specified 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. |
Converters consulted before applying the default JSON serialization rules.
Indicates whether Unicode characters are emitted without escaping.
Indicates whether null values are omitted from the output.
Creates a generator from the supplied serialization options.
options - configured generator options 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.
type - that this converter can handlenull
if no compatible converters are found for the given type.Collects the public readable properties of the given object for JSON object serialization.
object - the object whose properties should be collectedIndicates whether this JsonGenerator is configured to exclude fields by the given name.
name - of the field Indicates whether this JsonGenerator is configured to exclude values
of the given object (may be null).
value - an instance of an objectIndicates whether the given type should be excluded from the generated output.
type - the type to checktrue if the given type should not be output, else falseConverts an object to its JSON representation.
object - to convert to JSONSerializes array and writes it into specified buffer.
Serializes any char sequence and writes it into specified buffer.
Serializes date and writes it into specified buffer.
Serializes iterator and writes it into specified buffer.
Serializes map and writes it into specified buffer.
Serializes a map entry and writes it into specified buffer.
Serializes Number value and writes it into specified buffer.
Serializes an unnamed value and writes it into the specified buffer.
object - the value to serializebuffer - the output bufferSerializes object and writes it into specified buffer.
Serializes any char sequence and writes it into specified buffer without performing any manipulation of the given text.
Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.