Package org.qiunet.utils.json
Class JsonUtil
java.lang.Object
org.qiunet.utils.json.JsonUtil
json 工具类
- Author:
- qiunet
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.alibaba.fastjson.parser.ParserConfigstatic final com.alibaba.fastjson.serializer.SerializeConfig -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T>getGeneralList(String json, Class<T> c) 得到通用的列表static <T> List<T>getGeneralList(String json, Class<T> c, com.alibaba.fastjson.parser.ParserConfig config) 使用parseConfig 进行反序列化static <T> TgetGeneralObj(String jsonText, com.alibaba.fastjson.TypeReference<T> type, com.alibaba.fastjson.parser.Feature... features) 使用TYPE反序列化static <T> TgetGeneralObj(String jsonText, com.alibaba.fastjson.TypeReference<T> type, com.alibaba.fastjson.parser.ParserConfig parserConfig, com.alibaba.fastjson.parser.Feature... features) 使用自定义的parseConfigstatic <T> TgetGeneralObj(String jsonText, Class<T> clz, com.alibaba.fastjson.parser.Feature... features) 使用默认字段和Class反序列化对象static <T> TgetGeneralObj(String jsonText, Class<T> clz, com.alibaba.fastjson.parser.ParserConfig parserConfig, com.alibaba.fastjson.parser.Feature... features) 使用Class反序列化static <T> TgetGeneralObj(String jsonText, Type type, com.alibaba.fastjson.parser.Feature... features) static <T> TgetGeneralObj(String jsonText, Type type, com.alibaba.fastjson.parser.ParserConfig parserConfig, com.alibaba.fastjson.parser.Feature... features) static com.alibaba.fastjson.JSONObjecttoJsonObject(Object obj) 转成JsonObjectstatic com.alibaba.fastjson.JSONObjecttoJsonObject(Object obj, com.alibaba.fastjson.serializer.SerializeConfig config) 使用config序列化对象static String转换jsonstatic StringtoJsonString(Object o, com.alibaba.fastjson.serializer.SerializeConfig config, com.alibaba.fastjson.serializer.SerializerFeature... features) 转换jsonstatic StringtoJsonString(Object o, com.alibaba.fastjson.serializer.SerializerFeature... features) 转换json
-
Field Details
-
DEFAULT_PARSER_CONFIG
public static final com.alibaba.fastjson.parser.ParserConfig DEFAULT_PARSER_CONFIG -
DEFAULT_SERIALIZE_CONFIG
public static final com.alibaba.fastjson.serializer.SerializeConfig DEFAULT_SERIALIZE_CONFIG
-
-
Method Details
-
toJsonString
public static String toJsonString(Object o, com.alibaba.fastjson.serializer.SerializeConfig config, com.alibaba.fastjson.serializer.SerializerFeature... features) 转换json- Parameters:
o-- Returns:
-
toJsonString
public static String toJsonString(Object o, com.alibaba.fastjson.serializer.SerializerFeature... features) 转换json- Parameters:
o-- Returns:
-
toJsonString
转换json- Parameters:
o-- Returns:
-
getGeneralObj
public static <T> T getGeneralObj(String jsonText, Class<T> clz, com.alibaba.fastjson.parser.Feature... features) 使用默认字段和Class反序列化对象- Returns:
-
getGeneralObj
public static <T> T getGeneralObj(String jsonText, Class<T> clz, com.alibaba.fastjson.parser.ParserConfig parserConfig, com.alibaba.fastjson.parser.Feature... features) 使用Class反序列化- Returns:
- 对象
-
getGeneralObj
public static <T> T getGeneralObj(String jsonText, com.alibaba.fastjson.TypeReference<T> type, com.alibaba.fastjson.parser.Feature... features) 使用TYPE反序列化- Returns:
- 对象
-
getGeneralObj
-
getGeneralObj
public static <T> T getGeneralObj(String jsonText, com.alibaba.fastjson.TypeReference<T> type, com.alibaba.fastjson.parser.ParserConfig parserConfig, com.alibaba.fastjson.parser.Feature... features) 使用自定义的parseConfig -
getGeneralObj
-
getGeneralList
得到通用的列表- Parameters:
json-c-- Returns:
-
getGeneralList
public static <T> List<T> getGeneralList(String json, Class<T> c, com.alibaba.fastjson.parser.ParserConfig config) 使用parseConfig 进行反序列化- Type Parameters:
T-- Returns:
- 对象List
-
toJsonObject
转成JsonObject- Parameters:
obj-- Returns:
-
toJsonObject
public static com.alibaba.fastjson.JSONObject toJsonObject(Object obj, com.alibaba.fastjson.serializer.SerializeConfig config) 使用config序列化对象- Returns:
- JsonObject
-