com.seeyon.ctp.util.json.mapper
类 JSONMapper

java.lang.Object
  继承者 com.seeyon.ctp.util.json.mapper.JSONMapper

public class JSONMapper
extends java.lang.Object

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.


构造方法摘要
JSONMapper()
           
 
方法摘要
static java.lang.Class<?> getParameterizedTypeLocal()
           
static void setParameterizedTypeLocal(java.lang.Class<?> clz)
           
static java.lang.Object toJava(com.seeyon.ctp.util.json.model.JSONValue aValue)
          Map a JSON representation to a Java object.
static java.lang.Object toJava(com.seeyon.ctp.util.json.model.JSONValue aValue, java.lang.Class aPojoClass)
          Map a JSON representation to a Java object.
static com.seeyon.ctp.util.json.model.JSONValue toJSON(java.lang.Object aPojo)
          Map a POJO to the JSON representation.
static com.seeyon.ctp.util.json.model.JSONValue toJSONNOExtraAttr(java.lang.Object aPojo)
          返回不含额外属性(extraAttr)的PO的JSON
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

JSONMapper

public JSONMapper()
方法详细信息

setParameterizedTypeLocal

public static void setParameterizedTypeLocal(java.lang.Class<?> clz)

getParameterizedTypeLocal

public static java.lang.Class<?> getParameterizedTypeLocal()

toJava

public static java.lang.Object toJava(com.seeyon.ctp.util.json.model.JSONValue aValue,
                                      java.lang.Class aPojoClass)
                               throws MapperException
Map a JSON representation to a Java object.

参数:
aValue - The JSON value that has to be mapped.
aPojoClass - The class to which the JSON object should be mapped.
返回:
The resulting Java object, the POJO representation.
抛出:
MapperException - when an error occurs during mapping.

toJava

public static java.lang.Object toJava(com.seeyon.ctp.util.json.model.JSONValue aValue)
                               throws MapperException
Map a JSON representation to a Java object. Since no class nor type hint is passed to the mapper, this method can only handle the most basic mappings.

参数:
aValue - The JSON value that has to be mapped.
返回:
he resulting Java POJO.
抛出:
MapperException - When the JSON text cannot be mapped to POJO.

toJSON

public static com.seeyon.ctp.util.json.model.JSONValue toJSON(java.lang.Object aPojo)
                                                       throws MapperException
Map a POJO to the JSON representation.

参数:
aPojo - to be mapped to JSON.
返回:
The JSON representation.
抛出:
MapperException - If something goes wrong during mapping.

toJSONNOExtraAttr

public static com.seeyon.ctp.util.json.model.JSONValue toJSONNOExtraAttr(java.lang.Object aPojo)
                                                                  throws MapperException
返回不含额外属性(extraAttr)的PO的JSON

参数:
aPojo -
返回:
抛出:
MapperException