json工具类序列化和反序列化方法

类文件中,初始化:

private static final ObjectMapper MAPPER = new ObjectMapper();

String response = xxx;

response  {"id":"1","name":"zhangsan","password":"123",......}

将response的json字符串转为User对象(反序列化)

User user = MAPPER.readValue(response,User.class);

将User对象转为json字符串(序列化)

String value = MAPPER.writeValueAsString(user);
0

评论0

本站所有系统都含源码+数据库+导入视频+演示视频+典型代码讲解视频+售后答疑,需要联系客服微信:mtyeducation
没有账号? 注册  忘记密码?
豫ICP备19004322号-2