public final class JsonWriter extends java.lang.Object implements WalkObserver, java.lang.AutoCloseable
Modifier and Type | Class and Description |
---|---|
static class |
JsonWriter.EnumerableFormat
Configuration for writing of enumerable types.
|
Modifier and Type | Field and Description |
---|---|
static JsonWriter.EnumerableFormat |
DEFAULT_ENUMERABLE_FORMAT
Default configuration for enumerable types.
|
static java.lang.String |
DEFAULT_ITEM_SEPARATOR
Default item separator used when indent is not set (i.e.
|
static java.lang.String |
DEFAULT_ITEM_SEPARATOR_WITH_INDENT
Default item separator used when indent is not null.
|
static java.lang.String |
DEFAULT_KEY_SEPARATOR
Default key separator.
|
Constructor and Description |
---|
JsonWriter(java.io.Writer out)
Constructor.
|
JsonWriter(java.io.Writer out,
int indent)
Constructor.
|
JsonWriter(java.io.Writer out,
java.lang.String indent)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
beginArray(java.lang.Object array,
FieldInfo fieldInfo)
Called at the beginning of an array.
|
void |
beginCompound(java.lang.Object compound,
FieldInfo fieldInfo,
int elementIndex)
Called at the beginning of an compound field object.
|
void |
beginRoot(java.lang.Object compound)
Called for the root compound zserio object which is to be walked-through.
|
void |
close() |
void |
endArray(java.lang.Object array,
FieldInfo fieldInfo)
Called at the end of an array.
|
void |
endCompound(java.lang.Object compound,
FieldInfo fieldInfo,
int elementIndex)
Called at the end of just walked compound object.
|
void |
endRoot(java.lang.Object compound)
Called at the end of just walked root compound zserio object.
|
void |
setEnumerableFormat(JsonWriter.EnumerableFormat enumerableFormat)
Sets preferred formatting for enumerable types.
|
void |
setItemSeparator(java.lang.String itemSeparator)
Sets custom item separator.
|
void |
setKeySeparator(java.lang.String keySeparator)
Sets custom key separator.
|
void |
visitValue(java.lang.Object value,
FieldInfo fieldInfo,
int elementIndex)
Called when a simple (or an unset compound - i.e.
|
public static final java.lang.String DEFAULT_ITEM_SEPARATOR
public static final java.lang.String DEFAULT_ITEM_SEPARATOR_WITH_INDENT
public static final java.lang.String DEFAULT_KEY_SEPARATOR
public static final JsonWriter.EnumerableFormat DEFAULT_ENUMERABLE_FORMAT
public JsonWriter(java.io.Writer out)
out
- Writer to use for writing.public JsonWriter(java.io.Writer out, int indent)
out
- Writer to use for writing.indent
- Indent as a number of ' ' to be used for indentation.public JsonWriter(java.io.Writer out, java.lang.String indent)
out
- Writer to use for writing.indent
- Indent as a string to be used for indentation.public void setItemSeparator(java.lang.String itemSeparator)
itemSeparator
- Item separator to set.public void setKeySeparator(java.lang.String keySeparator)
keySeparator
- Key separator to set.public void setEnumerableFormat(JsonWriter.EnumerableFormat enumerableFormat)
enumerableFormat
- Enumerable format to use.public void close()
close
in interface java.lang.AutoCloseable
public void beginRoot(java.lang.Object compound)
WalkObserver
beginRoot
in interface WalkObserver
compound
- Root compound zserio object.public void endRoot(java.lang.Object compound)
WalkObserver
endRoot
in interface WalkObserver
compound
- Root compound zserio object.public void beginArray(java.lang.Object array, FieldInfo fieldInfo)
WalkObserver
beginArray
in interface WalkObserver
array
- Zserio array.fieldInfo
- Array field info.public void endArray(java.lang.Object array, FieldInfo fieldInfo)
WalkObserver
endArray
in interface WalkObserver
array
- Zserio array.fieldInfo
- Array field info.public void beginCompound(java.lang.Object compound, FieldInfo fieldInfo, int elementIndex)
WalkObserver
beginCompound
in interface WalkObserver
compound
- Compound zserio object.fieldInfo
- Compound field info.elementIndex
- Element index in array or NOT_ELEMENT if the compound is not in array.public void endCompound(java.lang.Object compound, FieldInfo fieldInfo, int elementIndex)
WalkObserver
endCompound
in interface WalkObserver
compound
- Compound zserio object.fieldInfo
- Compound field info.elementIndex
- Element index in array or NOT_ELEMENT if the compound is not in array.public void visitValue(java.lang.Object value, FieldInfo fieldInfo, int elementIndex)
WalkObserver
visitValue
in interface WalkObserver
value
- Simple value.fieldInfo
- Field info of the simple value.elementIndex
- Element index in array or NOT_ELEMENT if the compound is not in array.Last updated 2024-12-05 10:34:50