对象转json字符串案例

测试对象与json字符串的转换

 json字符串转对象

Stringstr = "{"id":"1001","name":"Java入门","price":19.88,"pnum":100,"category":"IT","description":"Good Book"}";

System.out.println(str);

      

//创建 "对象映射" 对象

ObjectMapper mapper = new ObjectMapper();

      

Book book = mapper.readValue(str, Book.class);

System.out.println(book);

原文地址:https://www.cnblogs.com/clc1996/p/11287740.html