java对象转json

来源:互联网 发布:saas数据库设计 编辑:程序博客网 时间:2024/05/21 13:00

List<Person> data= customerService.getPerson;

SONArray jsa = new JSONArray();

int jsaIndex= 0;


for (Person person: data) {

JSONObject item = new JSONObject();
item.put("name", person.getName());
item.put("code",person.getCode());
jsa.add(jsaIndex, item);
jsaIndex++;

}

0 0