Package org.jsonex.jsoncoder
Class BeanCoder
- java.lang.Object
-
- org.jsonex.jsoncoder.BeanCoder
-
public class BeanCoder extends Object
A coder to convert java class to a TDNodeFor 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
-
-
Constructor Summary
Constructors Constructor Description BeanCoder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectdecode(TDNode obj, Type type)Objectdecode(TDNode tdNode, Type type, Object targetObj, String name, BeanCoderContext ctx)<T> Tdecode(TDNode obj, T target)<T> TdeepClone(T src)<T> TdeepCopyTo(T src, T target)TDNodeencode(Object obj)TDNodeencode(Object obj, BeanCoderContext context, Type type)static BeanCoderget()
-
-
-
Field Detail
-
it
public static final org.jsonex.core.factory.InjectableInstance<BeanCoder> it
-
-
Method Detail
-
get
public static BeanCoder get()
-
encode
public TDNode encode(Object obj, BeanCoderContext context, Type type)
-
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 decodetype- The target type to decode totargetObj- The target object to decode to, if it's null, a new Object will be createdctx- The decode context- Returns:
- The decoded Object
-
-