Package com.fasterxml.jackson.jr.ob.impl
Class JSONWriter
java.lang.Object
com.fasterxml.jackson.jr.ob.impl.JSONWriter
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(int, com.fasterxml.jackson.jr.ob.impl.ValueWriterLocator, com.fasterxml.jackson.core.TreeCodec, com.fasterxml.jackson.core.JsonGenerator).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intprotected final com.fasterxml.jackson.core.JsonGeneratorprotected final TimeZoneprotected final com.fasterxml.jackson.core.TreeCodecprotected final booleanprotected final ValueWriterLocatorObject that is used to dynamically find Bean (and custom type) value writers -
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructor used for creating differently configured blueprint instancesprotectedJSONWriter(JSONWriter base, int features, ValueWriterLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonGenerator g) Constructor for non-blueprint instances. -
Method Summary
Modifier and TypeMethodDescriptionprotected void_checkUnknown(Object value) protected void_writeValue(Object value, int type) protected StringdateToString(Date v) intfeatures()booleanprotected StringkeyToString(Object rawKey) protected StringpathToString(Path value) perOperationInstance(int features, ValueWriterLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonGenerator g) withCacheCheck(int features) voidwriteBeanValue(BeanPropertyWriter[] props, Object bean) protected voidwriteBigDecimalField(String fieldName, BigDecimal v) protected voidprotected voidwriteBigIntegerField(String fieldName, BigInteger v) protected voidprotected voidwriteBinaryField(String fieldName, byte[] data) protected voidwriteBinaryValue(byte[] data) protected voidwriteBooleanArrayField(String fieldName, boolean[] v) protected voidwriteBooleanArrayValue(boolean[] v) protected voidwriteBooleanField(String fieldName, boolean v) protected voidwriteBooleanValue(boolean v) protected voidwriteCollectionField(String fieldName, Collection<?> v) protected voidprotected voidwriteDateField(String fieldName, Date v) protected voidprotected voidwriteDoubleArrayField(String fieldName, double[] v) protected voidwriteDoubleArrayValue(double[] v) protected voidwriteDoubleField(String fieldName, double v) protected voidwriteDoubleValue(double v) protected voidwriteEnumField(String fieldName, Enum<?> v) protected voidwriteEnumValue(Enum<?> v) voidwriteField(String fieldName, Object value, int type) protected voidwriteFloatArrayField(String fieldName, float[] v) protected voidwriteFloatArrayValue(float[] v) protected voidwriteFloatField(String fieldName, float v) protected voidwriteFloatValue(float v) protected voidwriteIntArrayField(String fieldName, int[] v) protected voidwriteIntArrayValue(int[] v) protected voidwriteIntField(String fieldName, int v) protected voidwriteIntValue(int v) protected voidwriteIterableField(String fieldName, Iterable<?> v) protected voidwriteIterableValue(Iterable<?> v) protected voidwriteListField(String fieldName, List<?> v) protected voidwriteListValue(List<?> list) protected voidwriteLongArrayField(String fieldName, long[] v) protected voidwriteLongArrayValue(long[] v) protected voidwriteLongField(String fieldName, long v) protected voidwriteLongValue(long v) protected voidwriteMapField(String fieldName, Map<?, ?> v) protected voidwriteMapValue(Map<?, ?> v) protected voidwriteNullField(com.fasterxml.jackson.core.io.SerializedString fieldName) protected voidwriteNullField(String fieldName) protected voidprotected voidwriteObjectArrayField(String fieldName, Object[] v) protected voidprotected voidwriteShortArrayField(String fieldName, short[] v) protected voidwriteShortArrayValue(short[] v) protected voidwriteStringField(String fieldName, String v) protected voidwriteStringLikeField(String fieldName, String v, int actualType) protected voidwriteStringLikeValue(String v, int actualType) protected voidprotected voidwriteTreeNodeField(String fieldName, com.fasterxml.jackson.core.TreeNode v) protected voidwriteTreeNodeValue(com.fasterxml.jackson.core.TreeNode v) protected voidwriteUnknownField(String fieldName, Object data) protected voidwriteUnknownValue(Object data) voidwriteValue(Object value) Main entry point for non-blueprint instances: called for the root value to write it out.
-
Field Details
-
_treeCodec
protected final com.fasterxml.jackson.core.TreeCodec _treeCodec -
_writerLocator
Object that is used to dynamically find Bean (and custom type) value writers -
_generator
protected final com.fasterxml.jackson.core.JsonGenerator _generator -
_timezone
-
_features
protected final int _features -
_writeNullValues
protected final boolean _writeNullValues
-
-
Constructor Details
-
JSONWriter
public JSONWriter()Constructor used for creating differently configured blueprint instances -
JSONWriter
protected JSONWriter(JSONWriter base, int features, ValueWriterLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonGenerator g) Constructor for non-blueprint instances.- Parameters:
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 use
-
-
Method Details
-
withCacheCheck
-
perOperationInstance
public JSONWriter perOperationInstance(int features, ValueWriterLocator loc, com.fasterxml.jackson.core.TreeCodec tc, com.fasterxml.jackson.core.JsonGenerator g) -
isEnabled
- Since:
- 2.11
-
features
public int features()- Since:
- 2.13
-
writeValue
Main entry point for non-blueprint instances: called for the root value to write it out.- Throws:
IOException
-
writeField
- Throws:
IOException
-
_writeValue
- Throws:
IOException
-
writeCollectionValue
- Throws:
IOException
-
writeCollectionField
- Throws:
IOException
-
writeIterableValue
- Throws:
IOException
-
writeIterableField
- Throws:
IOException
-
writeListValue
- Throws:
IOException
-
writeListField
- Throws:
IOException
-
writeMapValue
- Throws:
IOException
-
writeMapField
- Throws:
IOException
-
writeObjectArrayValue
- Throws:
IOException
-
writeObjectArrayField
- Throws:
IOException
-
writeIntArrayValue
- Throws:
IOException
-
writeIntArrayField
- Throws:
IOException
-
writeLongArrayValue
- Throws:
IOException
-
writeLongArrayField
- Throws:
IOException
-
writeBooleanArrayValue
- Throws:
IOException
-
writeBooleanArrayField
- Throws:
IOException
-
writeShortArrayValue
- Throws:
IOException
-
writeShortArrayField
- Throws:
IOException
-
writeFloatArrayValue
- Throws:
IOException
-
writeFloatArrayField
- Throws:
IOException
-
writeDoubleArrayValue
- Throws:
IOException
-
writeDoubleArrayField
- Throws:
IOException
-
writeTreeNodeValue
- Throws:
IOException
-
writeTreeNodeField
protected void writeTreeNodeField(String fieldName, com.fasterxml.jackson.core.TreeNode v) throws IOException - Throws:
IOException
-
writeBooleanValue
- Throws:
IOException
-
writeBooleanField
- Throws:
IOException
-
writeIntValue
- Throws:
IOException
-
writeIntField
- Throws:
IOException
-
writeLongValue
- Throws:
IOException
-
writeBigIntegerValue
- Throws:
IOException
-
writeBigIntegerField
- Throws:
IOException
-
writeLongField
- Throws:
IOException
-
writeFloatValue
- Throws:
IOException
-
writeFloatField
- Throws:
IOException
-
writeDoubleValue
- Throws:
IOException
-
writeDoubleField
- Throws:
IOException
-
writeBigDecimalValue
- Throws:
IOException
-
writeBigDecimalField
- Throws:
IOException
-
writeStringValue
- Throws:
IOException
-
writeStringField
- Throws:
IOException
-
writeStringLikeValue
- Throws:
IOException
-
writeStringLikeField
- Throws:
IOException
-
writeBinaryValue
- Throws:
IOException
-
writeBinaryField
- Throws:
IOException
-
writeNullValue
- Throws:
IOException
-
writeNullField
- Throws:
IOException
-
writeNullField
protected void writeNullField(com.fasterxml.jackson.core.io.SerializedString fieldName) throws IOException - Throws:
IOException
-
writeDateValue
- Throws:
IOException
-
writeDateField
- Throws:
IOException
-
writeEnumValue
- Throws:
IOException
-
writeEnumField
- Throws:
IOException
-
writeBeanValue
- Throws:
IOException
-
writeUnknownValue
- Throws:
IOException
-
writeUnknownField
- Throws:
IOException
-
_checkUnknown
- Throws:
IOException
-
keyToString
-
dateToString
- Since:
- 2.7
-
pathToString
- Since:
- 2.17
-