Package io.avaje.jsonb
Interface JsonWriter
-
- All Superinterfaces:
AutoCloseable,Closeable,Flushable
- All Known Subinterfaces:
BufferedJsonWriter,BytesJsonWriter
- All Known Implementing Classes:
DelegateJsonWriter
public interface JsonWriter extends Closeable, Flushable
Writes json content.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidallNames(PropertyNames names)Set the property names that will be used for all json generation.voidbeginArray()Write array begin.voidbeginObject()Write object begin.voidclose()Close the writer.voidemptyArray()Write empty array.voidendArray()Write array end.voidendObject()Write object end.voidflush()Flush the writer.voidjsonValue(Object value)Write a value that could be any value.voidname(int position)Set the next property name to write by position.voidname(String name)Set the next property name to write.voidnames(PropertyNames names)Set the current property names.voidnullValue()Write null value.Stringpath()Return the current path.voidpretty(boolean pretty)Set tp true to output json in pretty format.booleanserializeEmpty()Return true if empty collections should be serialised.voidserializeEmpty(boolean serializeEmpty)Set to serialise empty collections or not.booleanserializeNulls()Return true if null values should be serialised.voidserializeNulls(boolean serializeNulls)Set to serialise null values or not.voidvalue(boolean value)Write a boolean value.voidvalue(double value)Write a double value.voidvalue(int value)Write an int value.voidvalue(long value)Write a long value.voidvalue(Boolean value)Write a Boolean value.voidvalue(Double value)Write a Double value.voidvalue(Integer value)Write an Integer value.voidvalue(Long value)Write a Long value.voidvalue(String value)Write a string value.voidvalue(BigDecimal value)Write a BigDecimal value.voidvalue(BigInteger value)Write a BigInteger value.voidwriteNewLine()Write raw content.
-
-
-
Method Detail
-
serializeNulls
void serializeNulls(boolean serializeNulls)
Set to serialise null values or not.
-
serializeNulls
boolean serializeNulls()
Return true if null values should be serialised.
-
serializeEmpty
void serializeEmpty(boolean serializeEmpty)
Set to serialise empty collections or not.
-
serializeEmpty
boolean serializeEmpty()
Return true if empty collections should be serialised.
-
pretty
void pretty(boolean pretty)
Set tp true to output json in pretty format.
-
allNames
void allNames(PropertyNames names)
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
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).
-
names
void names(PropertyNames names)
Set the current property names.This is expected to be called per object after each call to
beginObject().
-
name
void name(int position)
Set the next property name to write by position. This uses the already encoded name values of PropertyNames.
-
name
void name(String name)
Set the next property name to write.This is generally less efficient than using
names(PropertyNames)andname(int).
-
beginArray
void beginArray()
Write array begin.
-
endArray
void endArray()
Write array end.
-
emptyArray
void emptyArray()
Write empty array.
-
beginObject
void beginObject()
Write object begin.
-
endObject
void endObject()
Write object end.
-
nullValue
void nullValue()
Write null value.
-
value
void value(boolean value)
Write a boolean value.
-
value
void value(int value)
Write an int value.
-
value
void value(long value)
Write a long value.
-
value
void value(double value)
Write a double value.
-
value
void value(BigDecimal value)
Write a BigDecimal value.
-
value
void value(BigInteger value)
Write a BigInteger value.
-
writeNewLine
void writeNewLine()
Write raw content. This is typically used to write new line characters forx-json-streamcontent.
-
close
void close()
Close the writer.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-