您的位置:首页 > 编程语言 > Java开发

eclipse 自动生成json格式的toString()方法

2013-02-27 12:53 627 查看






关键在这里点edit将下面的内容复制到文本框内,即可生成的代码即json格式的
{"${member.name()}":"${member.value}", "${otherMembers}"}


若对象中引入其他对象则生成的json格式是不正确的如:

{
"id": "9",
"img": "1363161532531.JPG",

此处的引号应去掉 “user”:{

"user": "{
"id": "1",
"name": "t",
"password": "t",
"tel": "",
"email": ""
}",

对应的这里也应该改掉 },

"address": "地址",
"lat": "31.859408",
"lon": "117.316827",
"unitprice": "0.0",
"area": "0.0",
"price": "0.0",
"descp": "信息",
"state": "1",
"type": "1",
"date": "2013-03-13 15:58:53"
}e": "1",
"img": "1363162505296.JPG",
"type": "1",
"date": "2013-03-13 16:15:05",
"user": {
"id": "1",
"email": "",
"name": "t",
"tel": "",
"password": "t"
},
"lat": "31.857139"
},
{
"id": "11",
"descp": "信息",
"unitprice": "0.0",
"lon": "117.319558",
"price": "0.0",
"area": "0.0",
"address": "地址",
"dis": 13975.950445244007,
"state": "1",
"img": "1363162523718.JPG",
"type": "1",
"date": "2013-03-13 16:15:23",
"user": {
"id": "1",
"email": "",
"name": "t",
"tel": "",
"password": "t"
},
"lat": "31.857936"
}
],
"state": 1
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: