各种转化

//对象转化为json
UserInfo userInfo=new UserInfo();        

userInfo.setName("lisi");        

userInfo.setUserId("2");        

ObjectMapper mapper = new ObjectMapper();        

ObjectWriter ow = mapper.writer().withDefaultPrettyPrinter();      

 String  json=ow.writeValueAsString(userInfo);

  

posted @ 2020-10-27 18:51  一个想飞的菜鸟  阅读(107)  评论(0编辑  收藏  举报