jackson的使用
作者:
后来_16db | 来源:发表于
2019-07-27 15:55 被阅读0次ObjectMapper mapper = new ObjectMapper();
User user = new User();
//pojo转json字符串
String json = mapper.writeValueAsString(user);
//json字符串转map
Map map = mapper.readValue(json, Map.class)
//map转json字符串
json = mapper.writeValueAsString(map);
//json字符串转pojo
User user = mapper.readValue(json, User.class)
//pojo转二进制数组
byte[] data = mapper.writeValueAsBytes(user);
//json字符串转JsonNode
JsonNode jsonNode = mapper.readTree(json);
//map转pojo
user = mapper.convertValue(map, User.class);
本文标题:jackson的使用
本文链接:https://www.haomeiwen.com/subject/klserctx.html
网友评论