Class DelegateJsonWriter
- All Implemented Interfaces:
JsonWriter,Closeable,Flushable,AutoCloseable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidallNames(PropertyNames names) Set the property names that will be used for all json generation.final voidWrite array begin.final voidWrite object begin.voidclose()Close the writer.final voidWrite empty array.final voidendArray()Write array end.final voidWrite object end.final voidflush()Flush the writer.final voidWrite a value that could be any value.voidMark the generated json as not completed due to an error.final voidname(int position) Set the next property name to write by position.final voidSet the next property name to write.final voidnames(PropertyNames names) Set the current property names.final voidWrite null value.final Stringpath()Return the current path.final voidpretty(boolean pretty) Set tp true to output json in pretty format.voidWrite raw JSON content.final booleanReturn true if empty collections should be serialised.final voidserializeEmpty(boolean serializeEmpty) Set to serialise empty collections or not.final booleanReturn true if null values should be serialised.final voidserializeNulls(boolean serializeNulls) Set to serialise null values or not.<T> TUnwrap the underlying generator being used.final voidvalue(boolean value) Write a boolean value.voidvalue(byte[] value) Write binary content as base64.final voidvalue(double value) Write a double value.final voidvalue(int value) Write an int value.final voidvalue(long value) Write a long value.final voidWrite a Boolean value.final voidWrite a Double value.final voidWrite an Integer value.final voidWrite a Long value.final voidWrite a string value.final voidvalue(BigDecimal value) Write a BigDecimal value.final voidvalue(BigInteger value) Write a BigInteger value.final voidWrite raw content.
-
Field Details
-
delegate
-
-
Constructor Details
-
DelegateJsonWriter
-
-
Method Details
-
unwrap
Description copied from interface:JsonWriterUnwrap the underlying generator being used.We do this to get access to the underlying generator. For the case when using jackson-core we get access to Jackson JsonGenerator and can then do Jackson specific things like set custom escaping.
try (JsonWriter writer = jsonb.writer(new StringWriter())) { // get access to the underlying Jackson JsonGenerator var generator = writer.unwrap(JsonGenerator.class) // do Jackson specific things like ... generator.setCharacterEscapes(new HTMLCharacterEscapes()); jsonb.toJson(myBean, writer); }- Specified by:
unwrapin interfaceJsonWriter
-
serializeNulls
public final void serializeNulls(boolean serializeNulls) Description copied from interface:JsonWriterSet to serialise null values or not.- Specified by:
serializeNullsin interfaceJsonWriter
-
serializeNulls
public final boolean serializeNulls()Description copied from interface:JsonWriterReturn true if null values should be serialised.- Specified by:
serializeNullsin interfaceJsonWriter
-
serializeEmpty
public final boolean serializeEmpty()Description copied from interface:JsonWriterReturn true if empty collections should be serialised.- Specified by:
serializeEmptyin interfaceJsonWriter
-
serializeEmpty
public final void serializeEmpty(boolean serializeEmpty) Description copied from interface:JsonWriterSet to serialise empty collections or not.- Specified by:
serializeEmptyin interfaceJsonWriter
-
pretty
public final void pretty(boolean pretty) Description copied from interface:JsonWriterSet tp true to output json in pretty format.- Specified by:
prettyin interfaceJsonWriter
-
path
Description copied from interface:JsonWriterReturn the current path.- Specified by:
pathin interfaceJsonWriter
-
beginArray
public final void beginArray()Description copied from interface:JsonWriterWrite array begin.- Specified by:
beginArrayin interfaceJsonWriter
-
endArray
public final void endArray()Description copied from interface:JsonWriterWrite array end.- Specified by:
endArrayin interfaceJsonWriter
-
emptyArray
public final void emptyArray()Description copied from interface:JsonWriterWrite empty array.- Specified by:
emptyArrayin interfaceJsonWriter
-
beginObject
public final void beginObject()Description copied from interface:JsonWriterWrite object begin.- Specified by:
beginObjectin interfaceJsonWriter
-
endObject
public final void endObject()Description copied from interface:JsonWriterWrite object end.- Specified by:
endObjectin interfaceJsonWriter
-
name
Description copied from interface:JsonWriterSet the next property name to write.This is generally less efficient than using
JsonWriter.names(PropertyNames)andJsonWriter.name(int).- Specified by:
namein interfaceJsonWriter
-
allNames
Description copied from interface:JsonWriterSet the property names that will be used for all json generation.These names should be used for all json generation for this generator and set once rather than set per object via
JsonWriter.names(PropertyNames).This is used by view json generation where all the names are known at the point when the view is created (a sort of flattened nested tree).
- Specified by:
allNamesin interfaceJsonWriter
-
names
Description copied from interface:JsonWriterSet the current property names.This is expected to be called per object after each call to
JsonWriter.beginObject().- Specified by:
namesin interfaceJsonWriter
-
name
public final void name(int position) Description copied from interface:JsonWriterSet the next property name to write by position. This uses the already encoded name values of PropertyNames.- Specified by:
namein interfaceJsonWriter
-
nullValue
public final void nullValue()Description copied from interface:JsonWriterWrite null value.- Specified by:
nullValuein interfaceJsonWriter
-
value
Description copied from interface:JsonWriterWrite a string value.- Specified by:
valuein interfaceJsonWriter
-
value
public final void value(boolean value) Description copied from interface:JsonWriterWrite a boolean value.- Specified by:
valuein interfaceJsonWriter
-
value
public final void value(int value) Description copied from interface:JsonWriterWrite an int value.- Specified by:
valuein interfaceJsonWriter
-
value
public final void value(long value) Description copied from interface:JsonWriterWrite a long value.- Specified by:
valuein interfaceJsonWriter
-
value
public final void value(double value) Description copied from interface:JsonWriterWrite a double value.- Specified by:
valuein interfaceJsonWriter
-
value
Description copied from interface:JsonWriterWrite a Boolean value.- Specified by:
valuein interfaceJsonWriter
-
value
Description copied from interface:JsonWriterWrite an Integer value.- Specified by:
valuein interfaceJsonWriter
-
value
Description copied from interface:JsonWriterWrite a Long value.- Specified by:
valuein interfaceJsonWriter
-
value
Description copied from interface:JsonWriterWrite a Double value.- Specified by:
valuein interfaceJsonWriter
-
value
Description copied from interface:JsonWriterWrite a BigDecimal value.- Specified by:
valuein interfaceJsonWriter
-
value
Description copied from interface:JsonWriterWrite a BigInteger value.- Specified by:
valuein interfaceJsonWriter
-
value
public void value(byte[] value) Description copied from interface:JsonWriterWrite binary content as base64.- Specified by:
valuein interfaceJsonWriter
-
rawValue
Description copied from interface:JsonWriterWrite raw JSON content.- Specified by:
rawValuein interfaceJsonWriter
-
jsonValue
Description copied from interface:JsonWriterWrite a value that could be any value.- Specified by:
jsonValuein interfaceJsonWriter
-
writeNewLine
public final void writeNewLine()Description copied from interface:JsonWriterWrite raw content. This is typically used to write new line characters forx-json-streamcontent.- Specified by:
writeNewLinein interfaceJsonWriter
-
flush
public final void flush()Description copied from interface:JsonWriterFlush the writer.- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceJsonWriter
-
close
public void close()Description copied from interface:JsonWriterClose the writer.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceJsonWriter
-
markIncomplete
public void markIncomplete()Description copied from interface:JsonWriterMark the generated json as not completed due to an error.This typically means not to flush or close an underlying OutputStream which allows it to be reset to then write some error response content instead.
- Specified by:
markIncompletein interfaceJsonWriter
-