1.需要json相关的jar包
2。设置json格式字符串:
字符串str=“{”student“:[{”name“:”leilei“,”age“:23},{”name“:”leilei02“,”age“:23}]}“
3。创建相应的类:
publicclassstudentlist{
list<student>student
publiclist<student>student(){
returnstudent
}
publicvoidsetstudent(list<student>student){这个学生=student
}
}
公共类student{
私有字符串名
私有intage
//privatestudentclassstudentclass
publicstringgetname(){
returnname
}
publicvoidsetname(stringname){这个名字=name
}
publicintgetage(){
returnage
}
publicvoidsetage(intage){这个年龄=4.测试程序
导入java.util.list
导入网址:org.codehaus.jackson.map.objectmapper对象映射器