从java valueobjects创建json对象时出错

时间:2014-09-01 08:07:46

标签: java json org.json

我正在尝试从我的java bean类创建一个json对象,首先我创建一个StringBuffer并将数据附加到其中,然后将此StringBuffer转换为String,同时转换此String进入json对象我收到此错误。

org.apache.sling.commons.json.JSONException: Expected a ':' after a key at character 129 of {data:{"id":"5345345","name":"dsfsdf","dep":"","ssc":"dgffdgfdg"},{"id":"123456","name":"SBI","dep":"654321","ssc":"State Bank"}}
第129页是第二封信。有没有语法问题?

1 个答案:

答案 0 :(得分:1)

将您的数据视为对象数组,

你的JSON应该是

{
    "data": [
        {
            "id": "5345345",
            "name": "dsfsdf",
            "dep": "",
            "ssc": "dgffdgfdg"
        },
        {
            "id": "123456",
            "name": "SBI",
            "dep": "654321",
            "ssc": "State Bank"
        }
    ]
}