0

我正在尝试从我的 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 位是倒数第二个字母。有语法问题吗?

4

1 回答 1

1

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

你的 JSON 应该是

{
    "data": [
        {
            "id": "5345345",
            "name": "dsfsdf",
            "dep": "",
            "ssc": "dgffdgfdg"
        },
        {
            "id": "123456",
            "name": "SBI",
            "dep": "654321",
            "ssc": "State Bank"
        }
    ]
}
于 2014-09-01T08:18:02.210 回答