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

来源:互联网 发布:宏业询价通道软件 编辑:程序博客网 时间:2024/05/16 02:30

关键在这里点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}