public class JsonListUtil {
    /**
     * List<T> 转 json 保存到数据库
     */
    public static <T> String listToJson(List<T> ts) {
        String jsons = JSON.toJSONString(ts);
        return jsons;
    }

    /**
     * json 转 List<T>
     */
    public static <T> List<T> jsonToList(String jsonString, Class<T> clazz) {
        @SuppressWarnings("unchecked")
        List<T> ts = (List<T>) JSONArray.parseArray(jsonString, clazz);
        return ts;
    }

}

相关文章:

  • 2022-12-23
  • 2021-06-12
  • 2021-12-31
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
猜你喜欢
  • 2021-09-22
  • 2022-12-23
  • 2021-12-12
  • 2022-02-26
  • 2022-12-23
  • 2021-12-31
  • 2021-12-23
相关资源
相似解决方案