将json格式map字符串转换成Map

ObjectMapper objectMapper = new ObjectMapper();
Map> maps = null;
try {
maps = objectMapper.readValue(entity.getCodeInfo(), Map.class);
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(maps.size());
Set key = maps.keySet();
Iterator iter = key.iterator();
while (iter.hasNext()) {
String field = iter.next();
System.out.println(field + ":" + maps.get(field));
}

你可能感兴趣的:(将json格式map字符串转换成Map)