Package org.cakelab.json.codec
Class JSONModeller
- java.lang.Object
-
- org.cakelab.json.codec.JSONModeller
-
public class JSONModeller extends java.lang.Object
Turns Java object into JSON object tree and vice versa.- Author:
- homac
-
-
Field Summary
Fields Modifier and Type Field Description protected JSONCodecConfiguration
cfg
protected ReflectionHelper
reflectionHelper
protected static java.lang.String
SPECIAL_ATTRIBUTE_CLASS
-
Constructor Summary
Constructors Constructor Description JSONModeller(JSONCodecConfiguration cfg)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
toJavaObject(java.lang.Object jsonAny, java.lang.Class<T> targetType)
<T> T
toJavaObject(java.lang.Object jsonAny, T targetObject)
java.lang.Object
toJSON(java.lang.Object javaObject)
Encodes the given Java object into a JSON object.java.lang.Object
toJSON(java.lang.Object o, java.lang.Class<?> referenceType)
returns a JSONObject, JSONArray or primitive value (including String) depending on the given object and reference type.
-
-
-
Field Detail
-
SPECIAL_ATTRIBUTE_CLASS
protected static final java.lang.String SPECIAL_ATTRIBUTE_CLASS
- See Also:
- Constant Field Values
-
reflectionHelper
protected ReflectionHelper reflectionHelper
-
cfg
protected JSONCodecConfiguration cfg
-
-
Constructor Detail
-
JSONModeller
public JSONModeller(JSONCodecConfiguration cfg)
-
-
Method Detail
-
toJavaObject
public <T> T toJavaObject(java.lang.Object jsonAny, T targetObject) throws JSONException
- Throws:
JSONException
-
toJavaObject
public <T> T toJavaObject(java.lang.Object jsonAny, java.lang.Class<T> targetType) throws JSONException
- Throws:
JSONException
-
toJSON
public java.lang.Object toJSON(java.lang.Object javaObject) throws JSONException
Encodes the given Java object into a JSON object.- Throws:
JSONException
-
toJSON
public java.lang.Object toJSON(java.lang.Object o, java.lang.Class<?> referenceType) throws JSONException
returns a JSONObject, JSONArray or primitive value (including String) depending on the given object and reference type.- Parameters:
o
- Object to be encoded.referenceType
- Class of the object or some subclass, in case you want just a particular subset of the members- Throws:
JSONException
-
-