Class DelegateJsonWriter
- All Implemented Interfaces:
JsonWriter,Closeable,Flushable,AutoCloseable
-
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.final voidbeginObject(PropertyNames names) Write object being and use the already encoded property names.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 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 new line characters typically forx-json-streamcontent.
-
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
Description copied from interface:JsonWriterSet to serialise null values or not.- Specified by:
serializeNullsin interfaceJsonWriter
-
serializeNulls
Description copied from interface:JsonWriterReturn true if null values should be serialised.- Specified by:
serializeNullsin interfaceJsonWriter
-
serializeEmpty
Description copied from interface:JsonWriterReturn true if empty collections should be serialised.- Specified by:
serializeEmptyin interfaceJsonWriter
-
serializeEmpty
Description copied from interface:JsonWriterSet to serialise empty collections or not.- Specified by:
serializeEmptyin interfaceJsonWriter
-
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
Description copied from interface:JsonWriterWrite array begin.- Specified by:
beginArrayin interfaceJsonWriter
-
endArray
Description copied from interface:JsonWriterWrite array end.- Specified by:
endArrayin interfaceJsonWriter
-
emptyArray
Description copied from interface:JsonWriterWrite empty array.- Specified by:
emptyArrayin interfaceJsonWriter
-
beginObject
Description copied from interface:JsonWriterWrite object being and use the already encoded property names.- Specified by:
beginObjectin interfaceJsonWriter
-
beginObject
Description copied from interface:JsonWriterWrite object begin.- Specified by:
beginObjectin interfaceJsonWriter
-
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.beginObject(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.beginObject(PropertyNames)(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
-
name
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
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
Description copied from interface:JsonWriterWrite a boolean value.- Specified by:
valuein interfaceJsonWriter
-
value
Description copied from interface:JsonWriterWrite an int 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 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
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
Description copied from interface:JsonWriterWrite new line characters typically forx-json-streamcontent.- Specified by:
writeNewLinein interfaceJsonWriter
-
flush
Description copied from interface:JsonWriterFlush the writer.- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceJsonWriter
-
close
Description copied from interface:JsonWriterClose the writer.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceJsonWriter
-
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
-