public class JSONWriter extends Object
JSONReader, writer does actually implement write methods itself
and uses delegation for only some special cases.
Life-cycle is such that initial instance (called blueprint)
is constructed first (including possible configuration
using mutant factory methods). This blueprint object
acts as a factory, and is never used for direct writing;
instead, per-call instance is created by calling
perOperationInstance(int, com.fasterxml.jackson.jr.ob.impl.ValueWriterLocator, com.fasterxml.jackson.core.TreeCodec, com.fasterxml.jackson.core.JsonGenerator).
| Modifier and Type | Field and Description |
|---|---|
protected int |
_features |
protected JsonGenerator |
_generator |
protected TimeZone |
_timezone |
protected TreeCodec |
_treeCodec |
protected boolean |
_writeNullValues |
protected ValueWriterLocator |
_writerLocator
Object that is used to dynamically find Bean (and custom type) value writers
|
| Modifier | Constructor and Description |
|---|---|
|
JSONWriter()
Constructor used for creating differently configured blueprint
instances
|
protected |
JSONWriter(JSONWriter base,
int features,
ValueWriterLocator loc,
TreeCodec tc,
JsonGenerator g)
Constructor for non-blueprint instances.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
_checkUnknown(Object value) |
protected void |
_writeValue(Object value,
int type) |
protected String |
dateToString(Date v) |
int |
features() |
boolean |
isEnabled(JSON.Feature f) |
protected String |
keyToString(Object rawKey) |
protected String |
pathToString(Path value) |
JSONWriter |
perOperationInstance(int features,
ValueWriterLocator loc,
TreeCodec tc,
JsonGenerator g) |
JSONWriter |
withCacheCheck(int features) |
void |
writeBeanValue(BeanPropertyWriter[] props,
Object bean) |
protected void |
writeBigDecimalField(String fieldName,
BigDecimal v) |
protected void |
writeBigDecimalValue(BigDecimal v) |
protected void |
writeBigIntegerField(String fieldName,
BigInteger v) |
protected void |
writeBigIntegerValue(BigInteger v) |
protected void |
writeBinaryField(String fieldName,
byte[] data) |
protected void |
writeBinaryValue(byte[] data) |
protected void |
writeBooleanArrayField(String fieldName,
boolean[] v) |
protected void |
writeBooleanArrayValue(boolean[] v) |
protected void |
writeBooleanField(String fieldName,
boolean v) |
protected void |
writeBooleanValue(boolean v) |
protected void |
writeCollectionField(String fieldName,
Collection<?> v) |
protected void |
writeCollectionValue(Collection<?> v) |
protected void |
writeDateField(String fieldName,
Date v) |
protected void |
writeDateValue(Date v) |
protected void |
writeDoubleField(String fieldName,
double v) |
protected void |
writeDoubleValue(double v) |
protected void |
writeEnumField(String fieldName,
Enum<?> v) |
protected void |
writeEnumValue(Enum<?> v) |
void |
writeField(String fieldName,
Object value,
int type) |
protected void |
writeFloatField(String fieldName,
float v) |
protected void |
writeFloatValue(float v) |
protected void |
writeIntArrayField(String fieldName,
int[] v) |
protected void |
writeIntArrayValue(int[] v) |
protected void |
writeIntField(String fieldName,
int v) |
protected void |
writeIntValue(int v) |
protected void |
writeIterableField(String fieldName,
Iterable<?> v) |
protected void |
writeIterableValue(Iterable<?> v) |
protected void |
writeListField(String fieldName,
List<?> v) |
protected void |
writeListValue(List<?> list) |
protected void |
writeLongArrayField(String fieldName,
long[] v) |
protected void |
writeLongArrayValue(long[] v) |
protected void |
writeLongField(String fieldName,
long v) |
protected void |
writeLongValue(long v) |
protected void |
writeMapField(String fieldName,
Map<?,?> v) |
protected void |
writeMapValue(Map<?,?> v) |
protected void |
writeNullField(SerializedString fieldName) |
protected void |
writeNullField(String fieldName) |
protected void |
writeNullValue() |
protected void |
writeObjectArrayField(String fieldName,
Object[] v) |
protected void |
writeObjectArrayValue(Object[] v) |
protected void |
writeStringField(String fieldName,
String v) |
protected void |
writeStringLikeField(String fieldName,
String v,
int actualType) |
protected void |
writeStringLikeValue(String v,
int actualType) |
protected void |
writeStringValue(String v) |
protected void |
writeTreeNodeField(String fieldName,
TreeNode v) |
protected void |
writeTreeNodeValue(TreeNode v) |
protected void |
writeUnknownField(String fieldName,
Object data) |
protected void |
writeUnknownValue(Object data) |
void |
writeValue(Object value)
Main entry point for non-blueprint instances: called for the root value to
write it out.
|
protected final TreeCodec _treeCodec
protected final ValueWriterLocator _writerLocator
protected final JsonGenerator _generator
protected final TimeZone _timezone
protected final int _features
protected final boolean _writeNullValues
public JSONWriter()
protected JSONWriter(JSONWriter base, int features, ValueWriterLocator loc, TreeCodec tc, JsonGenerator g)
base - Blueprint instance to base settings of the new instance onfeatures - Active features for the write operationloc - Helper object to use for dynamically located value writerstc - TreeCodec to use for writing tree values, if anyg - Underlying streaming encoder to usepublic JSONWriter withCacheCheck(int features)
public JSONWriter perOperationInstance(int features, ValueWriterLocator loc, TreeCodec tc, JsonGenerator g)
public boolean isEnabled(JSON.Feature f)
public int features()
public void writeValue(Object value) throws IOException
IOExceptionpublic void writeField(String fieldName, Object value, int type) throws IOException
IOExceptionprotected void _writeValue(Object value, int type) throws IOException
IOExceptionprotected void writeCollectionValue(Collection<?> v) throws IOException
IOExceptionprotected void writeCollectionField(String fieldName, Collection<?> v) throws IOException
IOExceptionprotected void writeIterableValue(Iterable<?> v) throws IOException
IOExceptionprotected void writeIterableField(String fieldName, Iterable<?> v) throws IOException
IOExceptionprotected void writeListValue(List<?> list) throws IOException
IOExceptionprotected void writeListField(String fieldName, List<?> v) throws IOException
IOExceptionprotected void writeMapValue(Map<?,?> v) throws IOException
IOExceptionprotected void writeMapField(String fieldName, Map<?,?> v) throws IOException
IOExceptionprotected void writeObjectArrayValue(Object[] v) throws IOException
IOExceptionprotected void writeObjectArrayField(String fieldName, Object[] v) throws IOException
IOExceptionprotected void writeIntArrayValue(int[] v)
throws IOException
IOExceptionprotected void writeIntArrayField(String fieldName, int[] v) throws IOException
IOExceptionprotected void writeLongArrayValue(long[] v)
throws IOException
IOExceptionprotected void writeLongArrayField(String fieldName, long[] v) throws IOException
IOExceptionprotected void writeBooleanArrayValue(boolean[] v)
throws IOException
IOExceptionprotected void writeBooleanArrayField(String fieldName, boolean[] v) throws IOException
IOExceptionprotected void writeTreeNodeValue(TreeNode v) throws IOException
IOExceptionprotected void writeTreeNodeField(String fieldName, TreeNode v) throws IOException
IOExceptionprotected void writeBooleanValue(boolean v)
throws IOException
IOExceptionprotected void writeBooleanField(String fieldName, boolean v) throws IOException
IOExceptionprotected void writeIntValue(int v)
throws IOException
IOExceptionprotected void writeIntField(String fieldName, int v) throws IOException
IOExceptionprotected void writeLongValue(long v)
throws IOException
IOExceptionprotected void writeBigIntegerValue(BigInteger v) throws IOException
IOExceptionprotected void writeBigIntegerField(String fieldName, BigInteger v) throws IOException
IOExceptionprotected void writeLongField(String fieldName, long v) throws IOException
IOExceptionprotected void writeFloatValue(float v)
throws IOException
IOExceptionprotected void writeFloatField(String fieldName, float v) throws IOException
IOExceptionprotected void writeDoubleValue(double v)
throws IOException
IOExceptionprotected void writeDoubleField(String fieldName, double v) throws IOException
IOExceptionprotected void writeBigDecimalValue(BigDecimal v) throws IOException
IOExceptionprotected void writeBigDecimalField(String fieldName, BigDecimal v) throws IOException
IOExceptionprotected void writeStringValue(String v) throws IOException
IOExceptionprotected void writeStringField(String fieldName, String v) throws IOException
IOExceptionprotected void writeStringLikeValue(String v, int actualType) throws IOException
IOExceptionprotected void writeStringLikeField(String fieldName, String v, int actualType) throws IOException
IOExceptionprotected void writeBinaryValue(byte[] data)
throws IOException
IOExceptionprotected void writeBinaryField(String fieldName, byte[] data) throws IOException
IOExceptionprotected void writeNullValue()
throws IOException
IOExceptionprotected void writeNullField(String fieldName) throws IOException
IOExceptionprotected void writeNullField(SerializedString fieldName) throws IOException
IOExceptionprotected void writeDateValue(Date v) throws IOException
IOExceptionprotected void writeDateField(String fieldName, Date v) throws IOException
IOExceptionprotected void writeEnumValue(Enum<?> v) throws IOException
IOExceptionprotected void writeEnumField(String fieldName, Enum<?> v) throws IOException
IOExceptionpublic void writeBeanValue(BeanPropertyWriter[] props, Object bean) throws IOException
IOExceptionprotected void writeUnknownValue(Object data) throws IOException
IOExceptionprotected void writeUnknownField(String fieldName, Object data) throws IOException
IOExceptionprotected void _checkUnknown(Object value) throws IOException
IOExceptionCopyright © 2025 FasterXML. All rights reserved.