net.neoremind.fountain.util
类 JsonUtils

java.lang.Object
  继承者 net.neoremind.fountain.util.JsonUtils

public abstract class JsonUtils
extends Object

JSON工具类

版本:
2013-4-17 下午4:25:22
作者:
Zhang Xu

构造方法摘要
JsonUtils()
           
 
方法摘要
static Object bytes2Object(byte[] jsonBytes, Class<?> c)
           
static Object convertValue(Object val, org.codehaus.jackson.type.JavaType type)
           
static org.codehaus.jackson.map.ObjectMapper getObjectMapper()
           
static
<T> T
json2GenericObject(String jsonString, org.codehaus.jackson.type.TypeReference<T> tr)
          JSON串转换为Java泛型对象,可以是各种类型,此方法最为强大。
static Object json2Object(String jsonString, Class<?> c)
          Json字符串转Java对象
static Object json2Object(String jsonString, org.codehaus.jackson.type.JavaType type)
           
static String toJson(Object object)
          Java对象转Json字符串
static String toJson(Object object, boolean ignoreEmpty)
           
static byte[] toJsonBytes(Object object)
           
static byte[] toJsonBytes(Object object, boolean ignoreEmpty)
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

JsonUtils

public JsonUtils()
方法详细信息

getObjectMapper

public static org.codehaus.jackson.map.ObjectMapper getObjectMapper()

json2GenericObject

public static <T> T json2GenericObject(String jsonString,
                                       org.codehaus.jackson.type.TypeReference<T> tr)
JSON串转换为Java泛型对象,可以是各种类型,此方法最为强大。用法看测试用例。

类型参数:
T -
参数:
jsonString - JSON字符串
tr - TypeReference,例如: new TypeReference< List >(){}
返回:
List对象列表

toJson

public static String toJson(Object object)
Java对象转Json字符串


toJsonBytes

public static byte[] toJsonBytes(Object object)

toJson

public static String toJson(Object object,
                            boolean ignoreEmpty)

toJsonBytes

public static byte[] toJsonBytes(Object object,
                                 boolean ignoreEmpty)

json2Object

public static Object json2Object(String jsonString,
                                 Class<?> c)
Json字符串转Java对象


bytes2Object

public static Object bytes2Object(byte[] jsonBytes,
                                  Class<?> c)

json2Object

public static Object json2Object(String jsonString,
                                 org.codehaus.jackson.type.JavaType type)

convertValue

public static Object convertValue(Object val,
                                  org.codehaus.jackson.type.JavaType type)


Copyright © 2016 neoremind. All rights reserved.