Class JSONMarshall

  • All Implemented Interfaces:
    Marshall

    public class JSONMarshall
    extends java.lang.Object
    implements Marshall
    • Constructor Detail

      • JSONMarshall

        public JSONMarshall()
    • Method Detail

      • marshall

        public JSONObject marshall​(boolean aValue)
        Description copied from interface: Marshall
        Convert a boolean primitive to JSON.
        Specified by:
        marshall in interface Marshall
        Returns:
        An JSON representation of the boolean primitive.
      • marshall

        public JSONObject marshall​(byte aValue)
        Description copied from interface: Marshall
        Convert a byte primitive to JSON.
        Specified by:
        marshall in interface Marshall
        Returns:
        An JSON representation of the byte primitive.
      • marshall

        public JSONObject marshall​(short aValue)
        Description copied from interface: Marshall
        Convert a short primitive to JSON.
        Specified by:
        marshall in interface Marshall
        Returns:
        An JSON representation of the short primitive.
      • marshall

        public JSONObject marshall​(char aValue)
        Description copied from interface: Marshall
        Convert a char primitive to JSON.
        Specified by:
        marshall in interface Marshall
        Returns:
        An JSON representation of the char primitive.
      • marshall

        public JSONObject marshall​(int aValue)
        Description copied from interface: Marshall
        Convert an int primitive to JSON.
        Specified by:
        marshall in interface Marshall
        Returns:
        An JSON representation of the int primitive.
      • marshall

        public JSONObject marshall​(long aValue)
        Description copied from interface: Marshall
        Convert a long primitive to JSON.
        Specified by:
        marshall in interface Marshall
        Returns:
        An JSON representation of the long primitive.
      • marshall

        public JSONObject marshall​(float aValue)
        Description copied from interface: Marshall
        Convert a float primitive to JSON.
        Specified by:
        marshall in interface Marshall
        Returns:
        An JSON representation of the float primitive.
      • marshall

        public JSONObject marshall​(double aValue)
        Description copied from interface: Marshall
        Convert a double primitive to JSON.
        Specified by:
        marshall in interface Marshall
        Returns:
        An JSON representation of the double primitive.
      • marshallPrimitive

        private JSONObject marshallPrimitive​(java.lang.String aType,
                                             java.lang.String aValue)
      • marshall

        public JSONObject marshall​(java.lang.Object aObj)
                            throws MarshallException
        Description copied from interface: Marshall
        Convert a Java object to JSON.
        Specified by:
        marshall in interface Marshall
        Returns:
        The JSON representation of the Java object.
        Throws:
        MarshallException - An error occured while converting the Java object to JSON.
      • marshallImplObject

        private JSONObject marshallImplObject​(java.lang.Object aObj,
                                              java.lang.String aObjId,
                                              java.lang.Class aObjClass,
                                              java.lang.String aObjClassName,
                                              java.util.HashMap aPool)
                                       throws MarshallException
        Throws:
        MarshallException
      • generateId

        private java.lang.String generateId()
      • unmarshall

        public MarshallValue unmarshall​(JSONObject aElement)
                                 throws MarshallException
        Description copied from interface: Marshall
        Convert a JSON representation to the Java primitive or reference.
        Specified by:
        unmarshall in interface Marshall
        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.
      • addHelper

        public void addHelper​(MarshallHelper aHelper)
        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.