java对象转JSON JS取JSON数据

时间:2014-05-13 08:55:21   收藏:0   阅读:285
JsonConfig config = new JsonConfig();
config.setJsonPropertyFilter(new PropertyFilter() {
@Override

public boolean apply(Object arg0, String arg1, Object arg2) {


// 过滤掉对象里的包含自己的属性(自己关联自己)

if (arg1.equals("wareTypes") || arg1.equals("skillS")) {
return true;
} else {
return false;
}
}
});


// 转化为JSON

JSONArray json = JSONArray.fromObject(userList, config);


JSP页面去数据

var obj = eval( "(" + data + ")" );//转换后的JSON对象
alert(obj[0].username);

java对象转JSON JS取JSON数据,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!