利用阿里巴巴的fastjson 提供的jar包,將string字符串轉成對象集合,首先需要引入依賴
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
其次是轉換的代碼
JSON.parseObject(JSON.toJSONString(jsonString), new TypeReference<ArrayList<Student>>(){});
注意:首先確保自己的jsonString一定是[{},{},{}]這樣格式的json字符串,Student是我自己定義的實體類對象,自己根據自己需要修改,才能正確轉換。