你的赛博博客

探索数字未来的边界

map转换 bean和list

转实体类

JSONObject JSONObj = JSONObject.parseObject(JSON.toJSONString(resultMap));
String result = JSONObj.get("result").toString();
PalletFroSpx palletFroSpx = new Gson().fromJson(result, PalletFroSpx.class);

转List
JSONObject JSONObj = JSONObject.parseObject(JSON.toJSONString(resultMap.get("data")));
String data = JSONObj.get("records").toString();
Type type = new TypeToken<List<PartsResult>>() {
}.getType();
//spx数据
List<PartsResult> list = new Gson().fromJson(data, type);
posted @ 2023-03-02 10:09  Aoul  阅读(83)  评论(0)    收藏  举报