Class JSONMarshall
java.lang.Object
com.sdicons.json.serializer.marshall.JSONMarshall
- All Implemented Interfaces:
Marshall
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringprivate longprivate static final Stringprivate HelperRepository<MarshallHelper> static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHelper(MarshallHelper aHelper) Add custom helper class.private Stringmarshall(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 JSONObjectmarshallImplArray(Object aObj, HashMap aPool) private JSONObjectmarshallImplObject(Object aObj, String aObjId, Class aObjClass, String aObjClassName, HashMap aPool) private JSONObjectmarshallPrimitive(String aType, String aValue) static voidrequireStringAttribute(JSONObject aElement, String anAttribute) unmarshall(JSONObject aElement) Convert a JSON representation to the Java primitive or reference.unmarshallImpl(JSONObject aElement, HashMap aObjectPool) private ObjectunmarshallImplPrimitive(JSONObject aElement) voidThe objects that fall back on the general object helper will be serialized by using their JavaBean properties.voidThe 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:MarshallConvert a boolean primitive to JSON. -
marshall
Description copied from interface:MarshallConvert a byte primitive to JSON. -
marshall
Description copied from interface:MarshallConvert a short primitive to JSON. -
marshall
Description copied from interface:MarshallConvert a char primitive to JSON. -
marshall
Description copied from interface:MarshallConvert an int primitive to JSON. -
marshall
Description copied from interface:MarshallConvert a long primitive to JSON. -
marshall
Description copied from interface:MarshallConvert a float primitive to JSON. -
marshall
Description copied from interface:MarshallConvert a double primitive to JSON. -
marshallPrimitive
-
marshall
Description copied from interface:MarshallConvert a Java object to JSON.- Specified by:
marshallin 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:MarshallConvert a JSON representation to the Java primitive or reference.- Specified by:
unmarshallin 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.
-