本文为小编原创文章,首发于Java识堂,一个高原创,高收藏,有干货的微信公众号,一起成长,一起进步,欢迎关注
前言
Jackson目前有2个版本
1.x版本包名为org.codehaus.jackson
2.x版本包名为com.fasterxml.jackson
使用
Spring Boot Web项目默认引入了Jackson,其他项目只要在pom文件中加入依赖即可
com.fasterxml.jackson.corejackson-core2.9.2com.fasterxml.jackson.corejackson-databind2.9.2com.fasterxml.jackson.corejackson-annotations2.9.2
生成JSON
@Datapublic class School { private String name; private String location; public School(String name, String location) { this.name = name; this.location = location; }}
@Datapublic class Person { private String name = "zhansan"; private int age = 100; private School[] schools = {new School("tsinghua