如果要把 Map<EnumType, List<DTO>>进行json后放入到数据库中是很方便的,唯一要注意的是枚举类型EnumType会进行toString操作存放,比如
{"MEMBER_CARD":[{"cardEntityId":"99180079","cardId":"186e245aca0e49fda00a36de7fee9fe1","code":"0000003366","id":"33ef1554cce743f0b6b1ad88041accae","isForceRatio":0,"mode":1,"name":"会员卡","ratio":100}]}
Map<EnumType,List<DTO>> map = JSON.parseObject(jsonText, Map.class)
Map<String, JSONArray> map = JSON.parseObject(promotion.getContent(), Map.class); JSONArray jsonArray = map.get(Promotion.Type.MEMBER_CARD.toString()); CardDto cardDto = jsonArray.getObject(0, CardDto.class);