使用fastjson,将字符串转数组时抛异常:
Resolved [com.alibaba.fastjson.JSONException: exepct '[', but string, pos
如下图中所示,result.getData()是一个字符串,我希望将它转为一个数组
我的做法是:
String res = JSON.toJSONString(result.getData()); List<TFDepartment> departmentList = JSONArray.parseArray(res, TFDepartment.class);
所以抛异常了:Resolved [com.alibaba.fastjson.JSONException: exepct '[', but string, pos
解决方案如下:
String res = JSON.toJSON(result.getData()).toString(); List<TFDepartment> departmentList = JSONArray.parseArray(res, TFDepartment.class);
来源:https://www.cnblogs.com/miaoying/p/12367114.html