Interface Marshall
-
- All Known Implementing Classes:
JSONMarshall
public interface Marshall
This interface represents the functionality to convert a JSON representation to/from a Java representation. The serializer's goal is to preserve as much Java structure as possible: primitive types, arrays, object clusters containing recursive references and so on. As a consequence, the generated JSON is rather terse. The serializer is the best choice in a Java centric application where you want to write some object structures to JSON in a readable form. If the emphasis is on clean JSON, take a look at the Mapper tool, which does not support all Java constructs but which emits nice JSON which can easily be parsed in e.g. Javascript. * The main difference between the serializer and the mapper is that the serializer keeps as much type information and structure information in the JSON data where the mapper uses the type information in the provided Java classes to interprete the JSON data.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description JSONObject
marshall(boolean aValue)
Convert a boolean primitive to JSON.JSONObject
marshall(byte aValue)
Convert a byte primitive to JSON.JSONObject
marshall(char aValue)
Convert a char primitive to JSON.JSONObject
marshall(double aValue)
Convert a double primitive to JSON.JSONObject
marshall(float aValue)
Convert a float primitive to JSON.JSONObject
marshall(int aValue)
Convert an int primitive to JSON.JSONObject
marshall(long aValue)
Convert a long primitive to JSON.JSONObject
marshall(short aValue)
Convert a short primitive to JSON.JSONObject
marshall(java.lang.Object aObj)
Convert a Java object to JSON.MarshallValue
unmarshall(JSONObject aElement)
Convert a JSON representation to the Java primitive or reference.
-
-
-
Method Detail
-
marshall
JSONObject marshall(boolean aValue)
Convert a boolean primitive to JSON.- Parameters:
aValue
-- Returns:
- An JSON representation of the boolean primitive.
-
marshall
JSONObject marshall(byte aValue)
Convert a byte primitive to JSON.- Parameters:
aValue
-- Returns:
- An JSON representation of the byte primitive.
-
marshall
JSONObject marshall(short aValue)
Convert a short primitive to JSON.- Parameters:
aValue
-- Returns:
- An JSON representation of the short primitive.
-
marshall
JSONObject marshall(char aValue)
Convert a char primitive to JSON.- Parameters:
aValue
-- Returns:
- An JSON representation of the char primitive.
-
marshall
JSONObject marshall(int aValue)
Convert an int primitive to JSON.- Parameters:
aValue
-- Returns:
- An JSON representation of the int primitive.
-
marshall
JSONObject marshall(long aValue)
Convert a long primitive to JSON.- Parameters:
aValue
-- Returns:
- An JSON representation of the long primitive.
-
marshall
JSONObject marshall(float aValue)
Convert a float primitive to JSON.- Parameters:
aValue
-- Returns:
- An JSON representation of the float primitive.
-
marshall
JSONObject marshall(double aValue)
Convert a double primitive to JSON.- Parameters:
aValue
-- Returns:
- An JSON representation of the double primitive.
-
marshall
JSONObject marshall(java.lang.Object aObj) throws MarshallException
Convert a Java object to JSON.- Parameters:
aObj
-- Returns:
- The JSON representation of the Java object.
- Throws:
MarshallException
- An error occured while converting the Java object to JSON.
-
unmarshall
MarshallValue unmarshall(JSONObject aElement) throws MarshallException
Convert a JSON representation to the Java primitive or reference.- 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.
-
-