public static PromoteActivityExt getExtByActivityDO(ActivityDO activityDO){ if(null==activityDO){ return null; } PromoteActivityExt activityExt = JSON.parseObject(activityDO.getFeature(), PromoteActivityExt.class); return activityExt; }
2、转列表:
List<ProjectRestDTO> list = JSONObject.parseArray(getlowestPriceStr(), ProjectRestDTO.class); System.out.println(list.toString());
3、HashMap: json 转HashMap
String operationParam = detailDO.getOperationParam(); HashMap<String,String> hashMap = JSON.parseObject(operationParam, HashMap.class); String discountValue = hashMap.get(OperationParamEnum.DISCOUNT_VALUE.getKey()); String brokerageRate = hashMap.get(OperationParamEnum.BROKERAGE_RATE.getKey()); channelInfo.setDiscount(Double.valueOf(discountValue)); channelInfo.setBrokerageRate(Integer.valueOf(brokerageRate));
HashMap转json转化:
Map paramMap = new HashMap(); paramMap.put(OperationParamEnum.DISCOUNT_VALUE.getKey(),String.valueOf(channelInfo.getDiscount())); paramMap.put(OperationParamEnum.BROKERAGE_RATE.getKey(),String.valueOf(channelInfo.getBrokerageRate())); activityDetailDO.setOperationParam(JSON.toJSONString(paramMap));