Jackson Data Binding Source Code

Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java".

  • Jackson Data Binding module allows you to converts JSON to and from POJO (Plain Old Java Object) using property accessor or using annotations.
  • Jackson Databind Source Code files are provided in the source packge (jackson-databind-2.12.4-sources.jar). You can download it at Jackson Maven Website.

    You can also browse Jackson Databind Source Code below:

    ✍: FYIcenter.com

    com/fasterxml/jackson/databind/JsonSerializable.java

    package com.fasterxml.jackson.databind;
    
    import java.io.IOException;
    
    import com.fasterxml.jackson.core.*;
    import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
    
    /**
     * Interface that can be implemented by objects that know how to
     * serialize themselves to JSON, using {@link JsonGenerator}
     * (and {@link SerializerProvider} if necessary).
     *<p>
     * Note that implementing this interface binds implementing object
     * closely to Jackson API, and that it is often not necessary to do
     * so -- if class is a bean, it can be serialized without
     * implementing this interface.
     *<p>
     * Note that while it is possible to just directly implement {@link JsonSerializable},
     * actual implementations are strongly recommended to instead extend
     * {@link JsonSerializable.Base}.
     */
    public interface JsonSerializable
    {
        /**
         * Serialization method called when no additional type information is
         * to be included in serialization.
         */
        public void serialize(JsonGenerator gen, SerializerProvider serializers) throws IOException;
    
        /**
         * Serialization method called when additional type information is
         * expected to be included in serialization, for deserialization to use.
         *<p>
         * Usually implementation consists of a call to {@link TypeSerializer#writeTypePrefix}
         * followed by serialization of contents,
         * followed by a call to {@link TypeSerializer#writeTypeSuffix}).
         * Details of the type id argument to pass depend on shape of JSON Object used
         * (Array, Object or scalar like String/Number/Boolean).
         *<p>
         * Note that some types (most notably, "natural" types: String, Integer,
         * Double and Boolean) never include type information.
         */
        public void serializeWithType(JsonGenerator gen, SerializerProvider serializers,
                TypeSerializer typeSer) throws IOException;
    
        /**
         * Base class with minimal implementation, as well as couple of extension methods
         * that core Jackson databinding makes use of.
         * Use of this base class is strongly recommended over directly implementing
         * {@link JsonSerializable}.
         *
         * @since 2.6
         */
        public abstract static class Base implements JsonSerializable
        {
            /**
             * Method that may be called on instance to determine if it is considered
             * "empty" for purposes of serialization filtering or not.
             */
            public boolean isEmpty(SerializerProvider serializers) {
                return false;
            }
        }
    }
    

    com/fasterxml/jackson/databind/JsonSerializable.java

     

    ⇒ Jackson Annotations Source Code

    ⇐ Download and Install Jackson Binary Package

    ⇑ Downloading and Reviewing jackson-*.jar

    ⇑⇑ Jackson - Java JSON library

    2022-03-29, 32004👍, 0💬