- All Implemented Interfaces:
JsonWriter
,Closeable
,Flushable
,AutoCloseable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
allNames
(PropertyNames names) Set the property names that will be used for all json generation.final void
Write array begin.final void
Write object begin.final void
beginObject
(PropertyNames names) Write object being and use the already encoded property names.void
close()
Close the writer.final void
Write empty array.final void
endArray()
Write array end.final void
Write object end.final void
flush()
Flush the writer.final void
Write a value that could be any value.void
Mark the generated json as not completed due to an error.final void
name
(int position) Set the next property name to write by position.final void
Set the next property name to write.final void
Write null value.final String
path()
Return the current path.final void
pretty
(boolean pretty) Set tp true to output json in pretty format.void
Write raw JSON content.final boolean
Return true if empty collections should be serialised.final void
serializeEmpty
(boolean serializeEmpty) Set to serialise empty collections or not.final boolean
Return true if null values should be serialised.final void
serializeNulls
(boolean serializeNulls) Set to serialise null values or not.<T> T
Unwrap the underlying generator being used.final void
value
(boolean value) Write a boolean value.void
value
(byte[] value) Write binary content as base64.final void
value
(double value) Write a double value.final void
value
(int value) Write an int value.final void
value
(long value) Write a long value.final void
Write a Boolean value.final void
Write a Double value.final void
Write an Integer value.final void
Write a Long value.final void
Write a string value.final void
value
(BigDecimal value) Write a BigDecimal value.final void
value
(BigInteger value) Write a BigInteger value.final void
Write new line characters typically forx-json-stream
content.
-
Field Details
-
delegate
-
-
Constructor Details
-
DelegateJsonWriter
-
-
Method Details
-
unwrap
Description copied from interface:JsonWriter
Unwrap 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:
unwrap
in interfaceJsonWriter
-
serializeNulls
public final void serializeNulls(boolean serializeNulls) Description copied from interface:JsonWriter
Set to serialise null values or not.- Specified by:
serializeNulls
in interfaceJsonWriter
-
serializeNulls
public final boolean serializeNulls()Description copied from interface:JsonWriter
Return true if null values should be serialised.- Specified by:
serializeNulls
in interfaceJsonWriter
-
serializeEmpty
public final boolean serializeEmpty()Description copied from interface:JsonWriter
Return true if empty collections should be serialised.- Specified by:
serializeEmpty
in interfaceJsonWriter
-
serializeEmpty
public final void serializeEmpty(boolean serializeEmpty) Description copied from interface:JsonWriter
Set to serialise empty collections or not.- Specified by:
serializeEmpty
in interfaceJsonWriter
-
pretty
public final void pretty(boolean pretty) Description copied from interface:JsonWriter
Set tp true to output json in pretty format.- Specified by:
pretty
in interfaceJsonWriter
-
path
Description copied from interface:JsonWriter
Return the current path.- Specified by:
path
in interfaceJsonWriter
-
beginArray
public final void beginArray()Description copied from interface:JsonWriter
Write array begin.- Specified by:
beginArray
in interfaceJsonWriter
-
endArray
public final void endArray()Description copied from interface:JsonWriter
Write array end.- Specified by:
endArray
in interfaceJsonWriter
-
emptyArray
public final void emptyArray()Description copied from interface:JsonWriter
Write empty array.- Specified by:
emptyArray
in interfaceJsonWriter
-
beginObject
Description copied from interface:JsonWriter
Write object being and use the already encoded property names.- Specified by:
beginObject
in interfaceJsonWriter
-
beginObject
public final void beginObject()Description copied from interface:JsonWriter
Write object begin.- Specified by:
beginObject
in interfaceJsonWriter
-
endObject
public final void endObject()Description copied from interface:JsonWriter
Write object end.- Specified by:
endObject
in interfaceJsonWriter
-
name
Description copied from interface:JsonWriter
Set the next property name to write.This is generally less efficient than using
JsonWriter.beginObject(PropertyNames)
andJsonWriter.name(int)
.- Specified by:
name
in interfaceJsonWriter
-
allNames
Description copied from interface:JsonWriter
Set 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:
allNames
in interfaceJsonWriter
-
name
public final void name(int position) Description copied from interface:JsonWriter
Set the next property name to write by position. This uses the already encoded name values of PropertyNames.- Specified by:
name
in interfaceJsonWriter
-
nullValue
public final void nullValue()Description copied from interface:JsonWriter
Write null value.- Specified by:
nullValue
in interfaceJsonWriter
-
value
Description copied from interface:JsonWriter
Write a string value.- Specified by:
value
in interfaceJsonWriter
-
value
public final void value(boolean value) Description copied from interface:JsonWriter
Write a boolean value.- Specified by:
value
in interfaceJsonWriter
-
value
public final void value(int value) Description copied from interface:JsonWriter
Write an int value.- Specified by:
value
in interfaceJsonWriter
-
value
public final void value(long value) Description copied from interface:JsonWriter
Write a long value.- Specified by:
value
in interfaceJsonWriter
-
value
public final void value(double value) Description copied from interface:JsonWriter
Write a double value.- Specified by:
value
in interfaceJsonWriter
-
value
Description copied from interface:JsonWriter
Write a Boolean value.- Specified by:
value
in interfaceJsonWriter
-
value
Description copied from interface:JsonWriter
Write an Integer value.- Specified by:
value
in interfaceJsonWriter
-
value
Description copied from interface:JsonWriter
Write a Long value.- Specified by:
value
in interfaceJsonWriter
-
value
Description copied from interface:JsonWriter
Write a Double value.- Specified by:
value
in interfaceJsonWriter
-
value
Description copied from interface:JsonWriter
Write a BigDecimal value.- Specified by:
value
in interfaceJsonWriter
-
value
Description copied from interface:JsonWriter
Write a BigInteger value.- Specified by:
value
in interfaceJsonWriter
-
value
public void value(byte[] value) Description copied from interface:JsonWriter
Write binary content as base64.- Specified by:
value
in interfaceJsonWriter
-
rawValue
Description copied from interface:JsonWriter
Write raw JSON content.- Specified by:
rawValue
in interfaceJsonWriter
-
jsonValue
Description copied from interface:JsonWriter
Write a value that could be any value.- Specified by:
jsonValue
in interfaceJsonWriter
-
writeNewLine
public final void writeNewLine()Description copied from interface:JsonWriter
Write new line characters typically forx-json-stream
content.- Specified by:
writeNewLine
in interfaceJsonWriter
-
flush
public final void flush()Description copied from interface:JsonWriter
Flush the writer.- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in interfaceJsonWriter
-
close
public void close()Description copied from interface:JsonWriter
Close the writer.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceJsonWriter
-
markIncomplete
public void markIncomplete()Description copied from interface:JsonWriter
Mark 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:
markIncomplete
in interfaceJsonWriter
-