//json转map 会出现map值为空,这个字段就不与转回
// 分为主动回填进去,和直接转通过getInnerMap()获取
Map<String,String> attributeMap = JSON.parseObject(parameter.getAttributes(),LinkedHashMap.class);
//先转为JSONObject
JSONObject attributes = JSON.parseObject(parameter.getAttributes());
// Map<String,Object> attributeMap=attributes.getInnerMap();
for (String key : attributes.keySet()) {
if (!StringUtils.isEmpty(attributes.get(key))) {
attributeMap.put(key, String.valueOf(attributes.get(key)));
} else {
attributeMap.put(key,"");
}
}
使用FastJson. 将Json转为其他类型时 出现参数为空时 不进行转化
最新推荐文章于 2024-07-04 09:24:51 发布