Fork me on GitHub

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  Views(70)  Comments(0Edit  收藏  举报