Top Description Fields Constructors Methods
com.fasterxml.jackson.jr.ob.impl

public Class JSONWriter

extends Object
Class Inheritance
Imports
java.io.*, java.math.BigDecimal, .BigInteger, java.nio.file.Path, java.util.*, com.fasterxml.jackson.core.*, com.fasterxml.jackson.core.io.SerializedString, com.fasterxml.jackson.jr.ob.JSON, .JSONObjectException, com.fasterxml.jackson.jr.ob.api.ValueWriter

Object that handles serialization of simple Objects into underlying data format (usually JSON). Unlike 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.

Field Summary

Modifier and TypeField and Description
protected final int
protected final JsonGenerator
protected final TimeZone
protected final TreeCodec
protected final boolean
protected final ValueWriterLocator
_writerLocator

Object that is used to dynamically find Bean (and custom type) value writers

private static final TimeZone

Constructor Summary

AccessConstructor and Description
public
JSONWriter()

Constructor used for creating differently configured blueprint instances

protected
JSONWriter(JSONWriter
Blueprint instance to base settings of the new instance on
base
,
int
Active features for the write operation
features
,
ValueWriterLocator
Helper object to use for dynamically located value writers
loc
,
TreeCodec
TreeCodec to use for writing tree values, if any
tc
,
JsonGenerator
Underlying streaming encoder to use
g
)

Constructor for non-blueprint instances.

Method Summary

Modifier and TypeMethod and Description
private void
_badType(int type, Object value)

protected void
protected void
_writeValue(Object value, int type)

protected String
public int
public boolean
protected String
protected String
public JSONWriter
public JSONWriter
withCacheCheck(int features)

public void
protected void
protected void
protected void
protected void
protected void
writeBinaryField(String fieldName, byte[] data)

protected void
writeBinaryValue(byte[] data)

protected void
writeBooleanArrayField(String fieldName, boolean[] v)

protected void
protected void
writeBooleanField(String fieldName, boolean v)

protected void
writeBooleanValue(boolean v)

protected void
protected void
protected void
writeDateField(String fieldName, Date v)

protected void
protected void
writeDoubleField(String fieldName, double v)

protected void
writeDoubleValue(double v)

protected void
writeEnumField(String fieldName, Enum<?> v)

protected void
public 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
protected void
writeIntField(String fieldName, int v)

protected void
protected void
protected void
protected void
writeListField(String fieldName, List<?> v)

protected void
protected void
writeLongArrayField(String fieldName, long[] v)

protected void
protected void
writeLongField(String fieldName, long v)

protected void
protected void
writeMapField(String fieldName, Map<?, ?> v)

protected void
writeMapValue(Map<?, ?> v)

protected void
protected void
protected void
protected void
protected void
protected void
protected void
writeStringLikeField(String fieldName, String v, int actualType)

protected void
writeStringLikeValue(String v, int actualType)

protected void
protected void
protected void
protected void
writeUnknownField(String fieldName, Object data)

protected void
public void
writeValue(Object value)

Main entry point for non-blueprint instances: called for the root value to write it out.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_featuresback to summary
protected final int _features
_generatorback to summary
protected final JsonGenerator _generator
_timezoneback to summary
protected final TimeZone _timezone
_treeCodecback to summary
protected final TreeCodec _treeCodec
_writeNullValuesback to summary
protected final boolean _writeNullValues
_writerLocatorback to summary
protected final ValueWriterLocator _writerLocator

Object that is used to dynamically find Bean (and custom type) value writers

DEFAULT_TIMEZONEback to summary
private static final TimeZone DEFAULT_TIMEZONE

Constructor Detail

JSONWriterback to summary
public JSONWriter()

Constructor used for creating differently configured blueprint instances

JSONWriterback to summary
protected JSONWriter(JSONWriter base, int features, ValueWriterLocator loc, TreeCodec tc, JsonGenerator g)

Constructor for non-blueprint instances.

Parameters
base:JSONWriter

Blueprint instance to base settings of the new instance on

features:int

Active features for the write operation

loc:ValueWriterLocator

Helper object to use for dynamically located value writers

tc:TreeCodec

TreeCodec to use for writing tree values, if any

g:JsonGenerator

Underlying streaming encoder to use

Method Detail

_badTypeback to summary
private void _badType(int type, Object value)
_checkUnknownback to summary
protected void _checkUnknown(Object value) throws IOException
_writeValueback to summary
protected void _writeValue(Object value, int type) throws IOException
dateToStringback to summary
protected String dateToString(Date v)
Since
2.7
featuresback to summary
public int features()
Since
2.13
isEnabledback to summary
public boolean isEnabled(JSON.Feature f)
Since
2.11
keyToStringback to summary
protected String keyToString(Object rawKey)
pathToStringback to summary
protected String pathToString(Path value)
Since
2.17
perOperationInstanceback to summary
public JSONWriter perOperationInstance(int features, ValueWriterLocator loc, TreeCodec tc, JsonGenerator g)
withCacheCheckback to summary
public JSONWriter withCacheCheck(int features)
writeBeanValueback to summary
public void writeBeanValue(BeanPropertyWriter[] props, Object bean) throws IOException
writeBigDecimalFieldback to summary
protected void writeBigDecimalField(String fieldName, BigDecimal v) throws IOException
writeBigDecimalValueback to summary
protected void writeBigDecimalValue(BigDecimal v) throws IOException
writeBigIntegerFieldback to summary
protected void writeBigIntegerField(String fieldName, BigInteger v) throws IOException
writeBigIntegerValueback to summary
protected void writeBigIntegerValue(BigInteger v) throws IOException
writeBinaryFieldback to summary
protected void writeBinaryField(String fieldName, byte[] data) throws IOException
writeBinaryValueback to summary
protected void writeBinaryValue(byte[] data) throws IOException
writeBooleanArrayFieldback to summary
protected void writeBooleanArrayField(String fieldName, boolean[] v) throws IOException
writeBooleanArrayValueback to summary
protected void writeBooleanArrayValue(boolean[] v) throws IOException
writeBooleanFieldback to summary
protected void writeBooleanField(String fieldName, boolean v) throws IOException
writeBooleanValueback to summary
protected void writeBooleanValue(boolean v) throws IOException
writeCollectionFieldback to summary
protected void writeCollectionField(String fieldName, Collection<?> v) throws IOException
writeCollectionValueback to summary
protected void writeCollectionValue(Collection<?> v) throws IOException
writeDateFieldback to summary
protected void writeDateField(String fieldName, Date v) throws IOException
writeDateValueback to summary
protected void writeDateValue(Date v) throws IOException
writeDoubleFieldback to summary
protected void writeDoubleField(String fieldName, double v) throws IOException
writeDoubleValueback to summary
protected void writeDoubleValue(double v) throws IOException
writeEnumFieldback to summary
protected void writeEnumField(String fieldName, Enum<?> v) throws IOException
writeEnumValueback to summary
protected void writeEnumValue(Enum<?> v) throws IOException
writeFieldback to summary
public void writeField(String fieldName, Object value, int type) throws IOException
writeFloatFieldback to summary
protected void writeFloatField(String fieldName, float v) throws IOException
writeFloatValueback to summary
protected void writeFloatValue(float v) throws IOException
writeIntArrayFieldback to summary
protected void writeIntArrayField(String fieldName, int[] v) throws IOException
writeIntArrayValueback to summary
protected void writeIntArrayValue(int[] v) throws IOException
writeIntFieldback to summary
protected void writeIntField(String fieldName, int v) throws IOException
writeIntValueback to summary
protected void writeIntValue(int v) throws IOException
writeIterableFieldback to summary
protected void writeIterableField(String fieldName, Iterable<?> v) throws IOException
writeIterableValueback to summary
protected void writeIterableValue(Iterable<?> v) throws IOException
writeListFieldback to summary
protected void writeListField(String fieldName, List<?> v) throws IOException
writeListValueback to summary
protected void writeListValue(List<?> list) throws IOException
writeLongArrayFieldback to summary
protected void writeLongArrayField(String fieldName, long[] v) throws IOException
writeLongArrayValueback to summary
protected void writeLongArrayValue(long[] v) throws IOException
writeLongFieldback to summary
protected void writeLongField(String fieldName, long v) throws IOException
writeLongValueback to summary
protected void writeLongValue(long v) throws IOException
writeMapFieldback to summary
protected void writeMapField(String fieldName, Map<?, ?> v) throws IOException
writeMapValueback to summary
protected void writeMapValue(Map<?, ?> v) throws IOException
writeNullFieldback to summary
protected void writeNullField(String fieldName) throws IOException
writeNullFieldback to summary
protected void writeNullField(SerializedString fieldName) throws IOException
writeNullValueback to summary
protected void writeNullValue() throws IOException
writeObjectArrayFieldback to summary
protected void writeObjectArrayField(String fieldName, Object[] v) throws IOException
writeObjectArrayValueback to summary
protected void writeObjectArrayValue(Object[] v) throws IOException
writeStringFieldback to summary
protected void writeStringField(String fieldName, String v) throws IOException
writeStringLikeFieldback to summary
protected void writeStringLikeField(String fieldName, String v, int actualType) throws IOException
writeStringLikeValueback to summary
protected void writeStringLikeValue(String v, int actualType) throws IOException
writeStringValueback to summary
protected void writeStringValue(String v) throws IOException
writeTreeNodeFieldback to summary
protected void writeTreeNodeField(String fieldName, TreeNode v) throws IOException
writeTreeNodeValueback to summary
protected void writeTreeNodeValue(TreeNode v) throws IOException
writeUnknownFieldback to summary
protected void writeUnknownField(String fieldName, Object data) throws IOException
writeUnknownValueback to summary
protected void writeUnknownValue(Object data) throws IOException
writeValueback to summary
public void writeValue(Object value) throws IOException

Main entry point for non-blueprint instances: called for the root value to write it out.