|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sdicons.json.mapper.JSONMapper
public class JSONMapper
The mapper class is able to convert a JSON representation to/from a Java representation. The mapper's goal is to produce a nice and clean JSON output which can easily be used in e.g. Javascript context. As a consequence, not all Java constructs are preserved during the conversion to/from JSON. The mapper is the best choice in an application where the clean JSON format is central. If the emphasis is on exact Java serialization where types are preserved, take a look at the Serializer tool. 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.
Constructor Summary | |
---|---|
JSONMapper()
|
Method Summary | |
---|---|
static void |
addHelper(SimpleMapperHelper aHelper)
Add custom helper class. |
static HelperRepository<SimpleMapperHelper> |
getRepository()
|
static Object |
toJava(JSONValue aValue)
Map a JSON representation to a Java object. |
static Object |
toJava(JSONValue aValue,
Class aPojoClass)
Map a JSON representation to a Java object. |
static Object |
toJava(JSONValue aValue,
ParameterizedType aGenericType)
Map a JSON representation to a Java object. |
static JSONValue |
toJSON(Object aPojo)
Map a POJO to the JSON representation. |
static void |
useJavaBeanAccess()
The objects that fall back on the general object mapper will be mapped by using their JavaBean properties. |
static void |
usePojoAccess()
The objects that fall back on the general object mapper will be mapped by using their fields directly. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JSONMapper()
Method Detail |
---|
public static Object toJava(JSONValue aValue, Class aPojoClass) throws MapperException
aValue
- The JSON value that has to be mapped.aPojoClass
- The class to which the JSON object should be mapped.
MapperException
- when an error occurs during mapping.public static Object toJava(JSONValue aValue, ParameterizedType aGenericType) throws MapperException
aValue
- The JSON value that has to be mapped.aGenericType
- A type indication to help the mapper map the JSON text.
MapperException
- When the JSON text cannot be mapped to POJO.public static Object toJava(JSONValue aValue) throws MapperException
aValue
- The JSON value that has to be mapped.
MapperException
- When the JSON text cannot be mapped to POJO.public static JSONValue toJSON(Object aPojo) throws MapperException
aPojo
- to be mapped to JSON.
MapperException
- If something goes wrong during mapping.public static void addHelper(SimpleMapperHelper aHelper)
aHelper
- the custom helper you want to add to the mapper.public static HelperRepository<SimpleMapperHelper> getRepository()
public static void usePojoAccess()
public static void useJavaBeanAccess()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |