Class BeanCoder


  • public class BeanCoder
    extends Object
    A coder to convert java class to a TDNode

    For an array or collection object, it will be encoded as TDNode of type ARRAY

    For Java Beans, it will be converted into TDNode of type MAP

    For some simple types such as Date, int, it will be converted TDNode of type SIMPLE

    As this encoder won't store any type information, it will only infer the type from the class. For collections fields, the element type information has to be specified with generic type. If not specified, the $type attribute need to be provided. Otherwise

    • Field Detail

      • it

        public static final org.jsonex.core.factory.InjectableInstance<BeanCoder> it
    • Constructor Detail

      • BeanCoder

        public BeanCoder()
    • Method Detail

      • decode

        public <T> T decode​(TDNode obj,
                            T target)
      • deepClone

        public <T> T deepClone​(T src)
      • deepCopyTo

        public <T> T deepCopyTo​(T src,
                                T target)
      • decode

        public Object decode​(TDNode tdNode,
                             Type type,
                             Object targetObj,
                             String name,
                             BeanCoderContext ctx)
        Parameters:
        tdNode - The json object to decode
        type - The target type to decode to
        targetObj - The target object to decode to, if it's null, a new Object will be created
        ctx - The decode context
        Returns:
        The decoded Object