0

我正在尝试从休息服务中解析 JSON。该服务不会将数据放入我认为 ItemFileReadStore 想要的格式,但我无法更改它。我在 dojo 库中找到的用于读取 JSON 数据的所有内容都需要一个标识符,而我的数据没有这个标识符。这是 JSON 数据:

  {"ChannelReadResponse":[
     {"Event":    {"@entityOrigin":"System","@entityId":"0x080e00000136ad8986520af104608052","Name":"Untitled","SymbolCode":"OHVPEV---------","TimeObserved":"2012-04-13T21:09:49.207Z","CreatedUser":"Helpdesk","ModifiedUser":"Helpdesk","CreatedTime":"2012-04-13T21:09:49.207Z","ModifiedTime":"2012-04-17T15:51:12.496Z"},

{"@entityOrigin":"System","@entityId":"0x080e00000136bb54ec770af104608028","Name":"我的事件","SymbolCode":"OHVPE----------","严重性": "SIGACT","Outcome":"Effective","TimeObserved":"2012-04-16T14:34:29.796Z","CreatedUser":"Helpdesk","ModifiedUser":"Helpdesk","CreatedTime":" 2012-04-16T14:34:29.796Z","ModifiedTime":"2012-04-17T15:50:52.499Z"} ],"频道":{"@writable":"false","@connected": "true","@entityId":"0x080e00000136ad8500760af104608064","Name":"Ozone", "Members":{"Member":[{"@entityOrigin":"System","@entityRef":"0x080e00000136ad8986520af104608052"},{"@entityOrigin":"System","@entityRef":"0x080e00000136bb54ec770af104608028"}] }}}, {"Event": {"@entityOrigin":"System ","@entityId":"0x080e00000136bc3c92d80af104608042","Name":"From2","SymbolCode":"OHVPE----------","TimeObserved":"2012-04-16T19:43: 03.150Z","CreatedUser":"Helpdesk","ModifiedUser":"Helpdesk","CreatedTime":"2012-04-16T19:43:03.150Z","ModifiedTime":"2012-04-16T19:43: 03.150Z"}, "频道": {"@writable":"false","@connected":"true","@entityId":"0x080e00000136bc3c92d80af104608034","Name":"Ozone2", "Members":{"Member":{"@entityOrigin":"System","@entityRef":"0x080e00000136bc3c92d80af104608042"}}} ]} ]}

有什么方法可以处理这些数据吗?我特别想要所有的事件。

4

2 回答 2

1

只需将其按摩成商店想要的形式即可。例如,如果您将数据返回到一个名为“data”的变量中,您可以轻松地执行以下操作:

    var json = {
        identifier: "@entityId",
        items: data
    };

然后只需使用json商店中的对象。

于 2012-04-17T20:31:07.650 回答
0

我只能考虑将您的 JSON 数据转换为 JavaScript Object Literal,然后将 ID 和 Name 添加到 JavaScript Object Literal....然后将其转换为 JSON,然后再将其传递给您的 Dojo Store。

我遇到过类似的问题,但我有幸将服务更改为返回带有标识符和名称的 JSON。我还没有尝试过我上面写的。

于 2012-04-17T17:33:18.750 回答