0

I have a JSON object coming from an API that looks something like:

{
  "version": "3.0.0",
  "posts": [
    {
      "id": 1,
      "title": "Some Post"
    },
    { ... }
  ]
}

But when the Ember app makes the request to the API (using the RESTAdapter), Ember gives me this error:

Your server returned a hash with the key version but you have no mapping for it.

Is there a way to handle, or otherwise ignore that key? The documentation explains how to handle an irregular key in the object, but I can't find anything about keys outside of the object. It seems like this would be a pretty common scenario.

Thanks!

4

1 回答 1

1

尽管如此,我不得不承认,这确实是一个非常常见的用例,即 JSON 响应将包含主对象之外的额外键,可悲的是在 ember-data 中,因为现在只支持两个额外的键,这metasince允许的。RESTSerializer.

有没有办法处理或忽略该键?

所以答案是,如果你不能改变你的后端不包括这个额外的键,它就不会像你已经看到的那样工作。

希望能帮助到你。

于 2013-08-07T07:25:31.280 回答