fastjson List 转Json , Json 转List
生活随笔
收集整理的這篇文章主要介紹了
fastjson List 转Json , Json 转List
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
比如說List<Strudent>
List轉Json
List<Student> students = new ArrayList(); String str = JSON.toJSONString(students); // List轉jsonJson 轉List 方法一
String json = ""; //獲取的Json數據 List<Student> students = JSON.parseObject(json,new TypeReference<List<Student>>(){}); // Json 轉ListJson 轉List方法二
List<Student> students = JSON.parseArray(json,Student.class);?
Student 對象要實現Serializable接口
import java.io.Serializable; public class Student implements Serializable{總結
以上是生活随笔為你收集整理的fastjson List 转Json , Json 转List的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为软件研发面试题1
- 下一篇: 群晖docker安装cms_Nas码农篇