程序包 com.sh.json

类 JSONSerializer

java.lang.Object
com.sh.json.JSONSerializer

public class JSONSerializer extends Object
Transforms java objects into JSON and back.
Transformation from java to JSON is pretty straightforward, but the other way around needs certain configuration, otherwise the java objects produced will be DynaBeans and Lists, because the JSON notation does not carry any information on java classes.
  • 构造器概要

    构造器
    构造器
    说明
     
  • 方法概要

    修饰符和类型
    方法
    说明
    static Object
    toJava(JSON json)
    Transform a JSON value to a java object.
    Depending on the configured values for conversion this will return a DynaBean, a bean, a List, or and array.
    static Object
    toJava(JSON json, JsonConfig jsonConfig)
    Transform a JSON value to a java object.
    Depending on the configured values for conversion this will return a DynaBean, a bean, a List, or and array.
    static JSON
    toJSON(Object object)
    Creates a JSONObject, JSONArray or a JSONNull from object.
    Accepts JSON formatted strings, Maps, arrays, Collections, DynaBeans and JavaBeans.
    static JSON
    toJSON(Object object, JsonConfig jsonConfig)
    Creates a JSONObject, JSONArray or a JSONNull from object.
    Accepts JSON formatted strings, Maps, arrays, Collections, DynaBeans and JavaBeans.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • JSONSerializer

      public JSONSerializer()
  • 方法详细资料

    • toJava

      public static Object toJava(JSON json)
      Transform a JSON value to a java object.
      Depending on the configured values for conversion this will return a DynaBean, a bean, a List, or and array.
      参数:
      json - a JSON value
      返回:
      depends on the nature of the source object (JSONObject, JSONArray, JSONNull).
    • toJava

      public static Object toJava(JSON json, JsonConfig jsonConfig)
      Transform a JSON value to a java object.
      Depending on the configured values for conversion this will return a DynaBean, a bean, a List, or and array.
      参数:
      json - a JSON value
      jsonConfig - additional configuration
      返回:
      depends on the nature of the source object (JSONObject, JSONArray, JSONNull) and the configured rootClass, classMap and arrayMode
    • toJSON

      public static JSON toJSON(Object object)
      Creates a JSONObject, JSONArray or a JSONNull from object.
      Accepts JSON formatted strings, Maps, arrays, Collections, DynaBeans and JavaBeans.
      参数:
      object - any java Object
      抛出:
      JSONException - if the object can not be converted
    • toJSON

      public static JSON toJSON(Object object, JsonConfig jsonConfig)
      Creates a JSONObject, JSONArray or a JSONNull from object.
      Accepts JSON formatted strings, Maps, arrays, Collections, DynaBeans and JavaBeans.
      参数:
      object - any java Object
      jsonConfig - additional configuration
      抛出:
      JSONException - if the object can not be converted