Class JSONWriter


  • public class JSONWriter
    extends java.lang.Object
    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.core.JsonGenerator).

    • Field Detail

      • _features

        protected final int _features
      • _writeNullValues

        protected final boolean _writeNullValues
      • _writerLocator

        protected final ValueWriterLocator _writerLocator
        Object that is used to dynamically find Bean (and custom type) value writers
      • _treeCodec

        protected final com.fasterxml.jackson.core.TreeCodec _treeCodec
      • _generator

        protected final com.fasterxml.jackson.core.JsonGenerator _generator
      • _timezone

        protected final java.util.TimeZone _timezone
    • Constructor Detail

      • JSONWriter

        public JSONWriter​(int features,
                          ValueWriterLocator td,
                          com.fasterxml.jackson.core.TreeCodec tc)
        Constructor used for creating differently configured blueprint instances
      • JSONWriter

        protected JSONWriter​(JSONWriter base,
                             int features,
                             ValueWriterLocator td,
                             com.fasterxml.jackson.core.JsonGenerator g)
        Constructor for non-blueprint instances
    • Method Detail

      • withCacheCheck

        public JSONWriter withCacheCheck​(int features)
      • with

        public JSONWriter with​(com.fasterxml.jackson.core.TreeCodec tc)
      • _with

        protected JSONWriter _with​(int features,
                                   ValueWriterLocator td,
                                   com.fasterxml.jackson.core.TreeCodec tc)
        Overridable method that all mutant factories call if a new instance is to be constructed
      • perOperationInstance

        public JSONWriter perOperationInstance​(int features,
                                               com.fasterxml.jackson.core.JsonGenerator g)
      • writeValue

        public void writeValue​(java.lang.Object value)
                        throws java.io.IOException
        Main entry point for non-blueprint instances: called for the root value to write it out.
        Throws:
        java.io.IOException
      • writeField

        public void writeField​(java.lang.String fieldName,
                               java.lang.Object value,
                               int type)
                        throws java.io.IOException
        Throws:
        java.io.IOException
      • _writeValue

        protected void _writeValue​(java.lang.Object value,
                                   int type)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCollectionValue

        protected void writeCollectionValue​(java.util.Collection<?> v)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeCollectionField

        protected void writeCollectionField​(java.lang.String fieldName,
                                            java.util.Collection<?> v)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIterableValue

        protected void writeIterableValue​(java.lang.Iterable<?> v)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIterableField

        protected void writeIterableField​(java.lang.String fieldName,
                                          java.lang.Iterable<?> v)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeListValue

        protected void writeListValue​(java.util.List<?> list)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeListField

        protected void writeListField​(java.lang.String fieldName,
                                      java.util.List<?> v)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeMapValue

        protected void writeMapValue​(java.util.Map<?,​?> v)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeMapField

        protected void writeMapField​(java.lang.String fieldName,
                                     java.util.Map<?,​?> v)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeObjectArrayValue

        protected void writeObjectArrayValue​(java.lang.Object[] v)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • writeObjectArrayField

        protected void writeObjectArrayField​(java.lang.String fieldName,
                                             java.lang.Object[] v)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIntArrayValue

        protected void writeIntArrayValue​(int[] v)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIntArrayField

        protected void writeIntArrayField​(java.lang.String fieldName,
                                          int[] v)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeLongArrayValue

        protected void writeLongArrayValue​(long[] v)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • writeLongArrayField

        protected void writeLongArrayField​(java.lang.String fieldName,
                                           long[] v)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBooleanArrayValue

        protected void writeBooleanArrayValue​(boolean[] v)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBooleanArrayField

        protected void writeBooleanArrayField​(java.lang.String fieldName,
                                              boolean[] v)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • writeTreeNodeValue

        protected void writeTreeNodeValue​(com.fasterxml.jackson.core.TreeNode v)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeTreeNodeField

        protected void writeTreeNodeField​(java.lang.String fieldName,
                                          com.fasterxml.jackson.core.TreeNode v)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBooleanValue

        protected void writeBooleanValue​(boolean v)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBooleanField

        protected void writeBooleanField​(java.lang.String fieldName,
                                         boolean v)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIntValue

        protected void writeIntValue​(int v)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeIntField

        protected void writeIntField​(java.lang.String fieldName,
                                     int v)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeLongValue

        protected void writeLongValue​(long v)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBigIntegerValue

        protected void writeBigIntegerValue​(java.math.BigInteger v)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBigIntegerField

        protected void writeBigIntegerField​(java.lang.String fieldName,
                                            java.math.BigInteger v)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeLongField

        protected void writeLongField​(java.lang.String fieldName,
                                      long v)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeDoubleValue

        protected void writeDoubleValue​(double v)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeDoubleField

        protected void writeDoubleField​(java.lang.String fieldName,
                                        double v)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBigDecimalValue

        protected void writeBigDecimalValue​(java.math.BigDecimal v)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBigDecimalField

        protected void writeBigDecimalField​(java.lang.String fieldName,
                                            java.math.BigDecimal v)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeStringValue

        protected void writeStringValue​(java.lang.String v)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeStringField

        protected void writeStringField​(java.lang.String fieldName,
                                        java.lang.String v)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeStringLikeValue

        protected void writeStringLikeValue​(java.lang.String v,
                                            int actualType)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeStringLikeField

        protected void writeStringLikeField​(java.lang.String fieldName,
                                            java.lang.String v,
                                            int actualType)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBinaryValue

        protected void writeBinaryValue​(byte[] data)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBinaryField

        protected void writeBinaryField​(java.lang.String fieldName,
                                        byte[] data)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • writeNullValue

        protected void writeNullValue()
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeNullField

        protected void writeNullField​(java.lang.String fieldName)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeNullField

        protected void writeNullField​(com.fasterxml.jackson.core.io.SerializedString fieldName)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeDateValue

        protected void writeDateValue​(java.util.Date v)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeDateField

        protected void writeDateField​(java.lang.String fieldName,
                                      java.util.Date v)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeEnumValue

        protected void writeEnumValue​(java.lang.Enum<?> v)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeEnumField

        protected void writeEnumField​(java.lang.String fieldName,
                                      java.lang.Enum<?> v)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • writeBeanValue

        public void writeBeanValue​(BeanPropertyWriter[] props,
                                   java.lang.Object bean)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • writeUnknownValue

        protected void writeUnknownValue​(java.lang.Object data)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • writeUnknownField

        protected void writeUnknownField​(java.lang.String fieldName,
                                         java.lang.Object data)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • _checkUnknown

        protected void _checkUnknown​(java.lang.Object value)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • keyToString

        protected java.lang.String keyToString​(java.lang.Object rawKey)
      • dateToString

        protected java.lang.String dateToString​(java.util.Date v)
        Since:
        2.7