Class JsonUtil

java.lang.Object
org.qiunet.utils.json.JsonUtil

public final class JsonUtil extends Object
json 工具类
Author:
qiunet
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.alibaba.fastjson.parser.ParserConfig
     
    static final com.alibaba.fastjson.serializer.SerializeConfig
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> List<T>
    得到通用的列表
    static <T> List<T>
    getGeneralList(String json, Class<T> c, com.alibaba.fastjson.parser.ParserConfig config)
    使用parseConfig 进行反序列化
    static <T> T
    getGeneralObj(String jsonText, com.alibaba.fastjson.TypeReference<T> type, com.alibaba.fastjson.parser.Feature... features)
    使用TYPE反序列化
    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
    static <T> T
    getGeneralObj(String jsonText, Class<T> clz, com.alibaba.fastjson.parser.Feature... features)
    使用默认字段和Class反序列化对象
    static <T> T
    getGeneralObj(String jsonText, Class<T> clz, com.alibaba.fastjson.parser.ParserConfig parserConfig, com.alibaba.fastjson.parser.Feature... features)
    使用Class反序列化
    static <T> T
    getGeneralObj(String jsonText, Type type, com.alibaba.fastjson.parser.Feature... features)
     
    static <T> T
    getGeneralObj(String jsonText, Type type, com.alibaba.fastjson.parser.ParserConfig parserConfig, com.alibaba.fastjson.parser.Feature... features)
     
    static com.alibaba.fastjson.JSONObject
    转成JsonObject
    static com.alibaba.fastjson.JSONObject
    toJsonObject(Object obj, com.alibaba.fastjson.serializer.SerializeConfig config)
    使用config序列化对象
    static String
    转换json
    static String
    toJsonString(Object o, com.alibaba.fastjson.serializer.SerializeConfig config, com.alibaba.fastjson.serializer.SerializerFeature... features)
    转换json
    static String
    toJsonString(Object o, com.alibaba.fastjson.serializer.SerializerFeature... features)
    转换json

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static String toJsonString(Object o)
      转换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

      public static <T> T getGeneralObj(String jsonText, Type type, com.alibaba.fastjson.parser.Feature... features)
    • 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

      public static <T> T getGeneralObj(String jsonText, Type type, com.alibaba.fastjson.parser.ParserConfig parserConfig, com.alibaba.fastjson.parser.Feature... features)
    • getGeneralList

      public static <T> List<T> getGeneralList(String json, Class<T> c)
      得到通用的列表
      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

      public static com.alibaba.fastjson.JSONObject toJsonObject(Object obj)
      转成JsonObject
      Parameters:
      obj -
      Returns:
    • toJsonObject

      public static com.alibaba.fastjson.JSONObject toJsonObject(Object obj, com.alibaba.fastjson.serializer.SerializeConfig config)
      使用config序列化对象
      Returns:
      JsonObject