Package groovy.json
Class DefaultJsonGenerator
- java.lang.Object
- 
- groovy.json.DefaultJsonGenerator
 
- 
- All Implemented Interfaces:
- JsonGenerator
 
 public class DefaultJsonGenerator extends java.lang.Object implements JsonGenerator A JsonGenerator that can be configured with variousJsonGenerator.Options. If the default options are sufficient consider using the staticJsonOutput.toJsonmethods.- Since:
- 2.5.0
- See Also:
- JsonGenerator.Options.build()
 
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classDefaultJsonGenerator.ClosureConverterA converter that handles converting a given type using a closure.- 
Nested classes/interfaces inherited from interface groovy.json.JsonGeneratorJsonGenerator.Converter, JsonGenerator.Options
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected java.util.Set<JsonGenerator.Converter>convertersprotected java.lang.StringdateFormatprotected java.util.LocaledateLocaleprotected booleandisableUnicodeEscapingprotected java.util.Set<java.lang.String>excludedFieldNamesprotected java.util.Set<java.lang.Class<?>>excludedFieldTypesprotected booleanexcludeNullsprotected java.util.TimeZonetimezone
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedDefaultJsonGenerator(JsonGenerator.Options options)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected JsonGenerator.ConverterfindConverter(java.lang.Class<?> type)Finds a converter that can handle the given type.protected java.util.Map<?,?>getObjectProperties(java.lang.Object object)booleanisExcludingFieldsNamed(java.lang.String name)Indicates whether this JsonGenerator is configured to exclude fields by the given name.booleanisExcludingValues(java.lang.Object value)Indicates whether this JsonGenerator is configured to exclude values of the given object (may benull).protected booleanshouldExcludeType(java.lang.Class<?> type)Indicates whether the given type should be excluded from the generated output.java.lang.StringtoJson(java.lang.Object object)Converts an object to its JSON representation.protected voidwriteArray(java.lang.Class<?> arrayClass, java.lang.Object array, CharBuf buffer)Serializes array and writes it into specified buffer.protected voidwriteCharSequence(java.lang.CharSequence seq, CharBuf buffer)Serializes any char sequence and writes it into specified buffer.protected voidwriteDate(java.util.Date date, CharBuf buffer)Serializes date and writes it into specified buffer.protected voidwriteIterator(java.util.Iterator<?> iterator, CharBuf buffer)Serializes iterator and writes it into specified buffer.protected voidwriteMap(java.util.Map<?,?> map, CharBuf buffer)Serializes map and writes it into specified buffer.protected voidwriteMapEntry(java.lang.String key, java.lang.Object value, CharBuf buffer)Serializes a map entry and writes it into specified buffer.protected voidwriteNumber(java.lang.Class<?> numberClass, java.lang.Number value, CharBuf buffer)Serializes Number value and writes it into specified buffer.protected voidwriteObject(java.lang.Object object, CharBuf buffer)protected voidwriteObject(java.lang.String key, java.lang.Object object, CharBuf buffer)Serializes object and writes it into specified buffer.protected voidwriteRaw(java.lang.CharSequence seq, CharBuf buffer)Serializes any char sequence and writes it into specified buffer without performing any manipulation of the given text.
 
- 
- 
- 
Field Detail- 
excludeNullsprotected final boolean excludeNulls 
 - 
disableUnicodeEscapingprotected final boolean disableUnicodeEscaping 
 - 
dateFormatprotected final java.lang.String dateFormat 
 - 
dateLocaleprotected final java.util.Locale dateLocale 
 - 
timezoneprotected final java.util.TimeZone timezone 
 - 
convertersprotected final java.util.Set<JsonGenerator.Converter> converters 
 - 
excludedFieldNamesprotected final java.util.Set<java.lang.String> excludedFieldNames 
 - 
excludedFieldTypesprotected final java.util.Set<java.lang.Class<?>> excludedFieldTypes 
 
- 
 - 
Constructor Detail- 
DefaultJsonGeneratorprotected DefaultJsonGenerator(JsonGenerator.Options options) 
 
- 
 - 
Method Detail- 
toJsonpublic java.lang.String toJson(java.lang.Object object) Converts an object to its JSON representation.- Specified by:
- toJsonin interface- JsonGenerator
- Parameters:
- object- to convert to JSON
- Returns:
- JSON
 
 - 
isExcludingFieldsNamedpublic boolean isExcludingFieldsNamed(java.lang.String name) Indicates whether this JsonGenerator is configured to exclude fields by the given name.- Specified by:
- isExcludingFieldsNamedin interface- JsonGenerator
- Parameters:
- name- of the field
- Returns:
- true if that field is being excluded, else false
 
 - 
isExcludingValuespublic boolean isExcludingValues(java.lang.Object value) Indicates whether this JsonGenerator is configured to exclude values of the given object (may benull).- Specified by:
- isExcludingValuesin interface- JsonGenerator
- Parameters:
- value- an instance of an object
- Returns:
- true if values like this are being excluded, else false
 
 - 
writeNumberprotected void writeNumber(java.lang.Class<?> numberClass, java.lang.Number value, CharBuf buffer)Serializes Number value and writes it into specified buffer.
 - 
writeObjectprotected void writeObject(java.lang.Object object, CharBuf buffer)
 - 
writeObjectprotected void writeObject(java.lang.String key, java.lang.Object object, CharBuf buffer)Serializes object and writes it into specified buffer.
 - 
getObjectPropertiesprotected java.util.Map<?,?> getObjectProperties(java.lang.Object object) 
 - 
writeCharSequenceprotected void writeCharSequence(java.lang.CharSequence seq, CharBuf buffer)Serializes any char sequence and writes it into specified buffer.
 - 
writeRawprotected void writeRaw(java.lang.CharSequence seq, CharBuf buffer)Serializes any char sequence and writes it into specified buffer without performing any manipulation of the given text.
 - 
writeDateprotected void writeDate(java.util.Date date, CharBuf buffer)Serializes date and writes it into specified buffer.
 - 
writeArrayprotected void writeArray(java.lang.Class<?> arrayClass, java.lang.Object array, CharBuf buffer)Serializes array and writes it into specified buffer.
 - 
writeMapprotected void writeMap(java.util.Map<?,?> map, CharBuf buffer)Serializes map and writes it into specified buffer.
 - 
writeMapEntryprotected void writeMapEntry(java.lang.String key, java.lang.Object value, CharBuf buffer)Serializes a map entry and writes it into specified buffer.
 - 
writeIteratorprotected void writeIterator(java.util.Iterator<?> iterator, CharBuf buffer)Serializes iterator and writes it into specified buffer.
 - 
findConverterprotected JsonGenerator.Converter findConverter(java.lang.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. Anullvalue 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 nullif no compatible converters are found for the given type.
 
 - 
shouldExcludeTypeprotected boolean shouldExcludeType(java.lang.Class<?> type) Indicates whether the given type should be excluded from the generated output.- Parameters:
- type- the type to check
- Returns:
- trueif the given type should not be output, else- false
 
 
- 
 
-