Class JSONMarshall
java.lang.Object
com.sdicons.json.serializer.marshall.JSONMarshall
- All Implemented Interfaces:
Marshall
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
private long
private static final String
private HelperRepository
<MarshallHelper> static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addHelper
(MarshallHelper aHelper) Add custom helper class.private String
marshall
(boolean aValue) Convert a boolean primitive to JSON.marshall
(byte aValue) Convert a byte primitive to JSON.marshall
(char aValue) Convert a char primitive to JSON.marshall
(double aValue) Convert a double primitive to JSON.marshall
(float aValue) Convert a float primitive to JSON.marshall
(int aValue) Convert an int primitive to JSON.marshall
(long aValue) Convert a long primitive to JSON.marshall
(short aValue) Convert a short primitive to JSON.Convert a Java object to JSON.marshallImpl
(Object aObj, HashMap aPool) private JSONObject
marshallImplArray
(Object aObj, HashMap aPool) private JSONObject
marshallImplObject
(Object aObj, String aObjId, Class aObjClass, String aObjClassName, HashMap aPool) private JSONObject
marshallPrimitive
(String aType, String aValue) static void
requireStringAttribute
(JSONObject aElement, String anAttribute) unmarshall
(JSONObject aElement) Convert a JSON representation to the Java primitive or reference.unmarshallImpl
(JSONObject aElement, HashMap aObjectPool) private Object
unmarshallImplPrimitive
(JSONObject aElement) void
The objects that fall back on the general object helper will be serialized by using their JavaBean properties.void
The objects that fall back on the general object helper will be serialized by using their fields directly.
-
Field Details
-
IDPREFIX
- See Also:
-
idCounter
private long idCounter -
RNDR_NULL
- See Also:
-
RNDR_OBJ
- See Also:
-
RNDR_OBJREF
- See Also:
-
RNDR_PRIM
- See Also:
-
RNDR_ARR
- See Also:
-
RNDR_ATTR_ID
- See Also:
-
RNDR_ATTR_KIND
- See Also:
-
RNDR_ATTR_TYPE
- See Also:
-
RNDR_ATTR_VALUE
- See Also:
-
RNDR_ATTR_CLASS
- See Also:
-
RNDR_ATTR_REF
- See Also:
-
RNDR_PRTITYP_BOOLEAN
- See Also:
-
RNDR_PRTITYP_BYTE
- See Also:
-
RNDR_PRTITYP_CHAR
- See Also:
-
RNDR_PRTITYP_SHORT
- See Also:
-
RNDR_PRTITYP_INT
- See Also:
-
RNDR_PRTITYP_LONG
- See Also:
-
RNDR_PRTITYP_FLOAT
- See Also:
-
RNDR_PRTITYP_DOUBLE
- See Also:
-
ERR_MISSINGATTR
- See Also:
-
ERR_MISSINGATTRVAL
- See Also:
-
ERR_MISSINGSTRING
- See Also:
-
repo
-
-
Constructor Details
-
JSONMarshall
public JSONMarshall()
-
-
Method Details
-
marshall
Description copied from interface:Marshall
Convert a boolean primitive to JSON. -
marshall
Description copied from interface:Marshall
Convert a byte primitive to JSON. -
marshall
Description copied from interface:Marshall
Convert a short primitive to JSON. -
marshall
Description copied from interface:Marshall
Convert a char primitive to JSON. -
marshall
Description copied from interface:Marshall
Convert an int primitive to JSON. -
marshall
Description copied from interface:Marshall
Convert a long primitive to JSON. -
marshall
Description copied from interface:Marshall
Convert a float primitive to JSON. -
marshall
Description copied from interface:Marshall
Convert a double primitive to JSON. -
marshallPrimitive
-
marshall
Description copied from interface:Marshall
Convert a Java object to JSON.- Specified by:
marshall
in interfaceMarshall
- Parameters:
aObj
-- Returns:
- The JSON representation of the Java object.
- Throws:
MarshallException
- An error occured while converting the Java object to JSON.
-
marshallImpl
- Throws:
MarshallException
-
marshallImplArray
- Throws:
MarshallException
-
marshallImplObject
private JSONObject marshallImplObject(Object aObj, String aObjId, Class aObjClass, String aObjClassName, HashMap aPool) throws MarshallException - Throws:
MarshallException
-
generateId
-
unmarshall
Description copied from interface:Marshall
Convert a JSON representation to the Java primitive or reference.- Specified by:
unmarshall
in interfaceMarshall
- Parameters:
aElement
-- Returns:
- The Java representation of the JSON. This value can represent a Java primitive value or it can represent a Java reference.
- Throws:
MarshallException
- An error occured while trying to convert the JSON representation into a Java representation.
-
unmarshallImpl
- Throws:
MarshallException
-
unmarshallImplPrimitive
- Throws:
MarshallException
-
requireStringAttribute
public static void requireStringAttribute(JSONObject aElement, String anAttribute) throws MarshallException - Throws:
MarshallException
-
addHelper
Add custom helper class.- Parameters:
aHelper
- the custom helper you want to add to the serializer.
-
usePojoAccess
public void usePojoAccess()The objects that fall back on the general object helper will be serialized by using their fields directly. Without further annotations, the default constructor without arguments will be used in the POJO. If this is not sufficient, the @JSONConstruct and @JSONSerialize annotations can be used as well in the POJO to indicate which constructor has to be used. -
useJavaBeanAccess
public void useJavaBeanAccess()The objects that fall back on the general object helper will be serialized by using their JavaBean properties. The JavaBean always needs a default constructor without arguments.
-