Class JSONMarshall

java.lang.Object
com.sdicons.json.serializer.marshall.JSONMarshall
All Implemented Interfaces:
Marshall

public class JSONMarshall extends Object implements Marshall
  • Field Details

  • Constructor Details

    • JSONMarshall

      public JSONMarshall()
  • Method Details

    • marshall

      public JSONObject marshall(boolean aValue)
      Description copied from interface: Marshall
      Convert a boolean primitive to JSON.
      Specified by:
      marshall in interface Marshall
      Parameters:
      aValue -
      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
      Parameters:
      aValue -
      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
      Parameters:
      aValue -
      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
      Parameters:
      aValue -
      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
      Parameters:
      aValue -
      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
      Parameters:
      aValue -
      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
      Parameters:
      aValue -
      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
      Parameters:
      aValue -
      Returns:
      An JSON representation of the double primitive.
    • marshall

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

      public JSONObject marshallImpl(Object aObj, HashMap aPool) throws MarshallException
      Throws:
      MarshallException
    • 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
      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

      public Object unmarshallImpl(JSONObject aElement, HashMap aObjectPool) throws MarshallException
      Throws:
      MarshallException
    • requireStringAttribute

      public static void requireStringAttribute(JSONObject aElement, String anAttribute) throws MarshallException
      Throws:
      MarshallException
    • 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.