对象转json字符串案例
程序员文章站
2022-04-30 19:52:49
测试对象与json字符串的转换 json字符串转对象 Stringstr = "{\"id\":\"1001\",\"name\":\"Java入门\",\"price\":19.88,\"pnum\":100,\"category\":\"IT\",\"description\":\"Good B ......
测试对象与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); |
上一篇: web-CSS居中大全
下一篇: javascript —— this