eclipse生成toString()自定义Json字符串,tostringjson
分享于 点击 23423 次 点评:107
eclipse生成toString()自定义Json字符串,tostringjson
[java] view plain copy- 关键在这里点edit将下面的内容复制到文本框内,即可生成的代码即json格式的
- {"${member.name()}":"${member.value}", "${otherMembers}"}
若对象中引入其他对象则生成的json格式是不正确的如:
[java] view plain copy- {
- "id": "9",
- "img": "1363161532531.JPG",
此处的引号应去掉 “user”:{
[java] view plain copy- "user": "{
- "id": "1",
- "name": "t",
- "password": "t",
- "tel": "",
- "email": ""
- }",<span border:none;">white-space:pre;"> </span>
对应的这里也应该改掉 },
[java] view plain copy- <span style="white-space:pre;"> </span>
- "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
- }
相关文章
- 暂无相关文章
用户点评