与Emberjs的Strongloop

时间:2015-04-25 09:15:30

标签: ember.js loopbackjs strongloop

Ember Data的REST适配器以这种格式接受来自服务器的JSON:

取自文档:http://guides.emberjs.com/v1.10.0/models/the-rest-adapter/

{
  "post": {
    "id": 1,
    "title": "Node is not omakase",
    "comments": [1, 2, 3]
  },

  "comments": [{
    "id": 1,
    "body": "But is it _lightweight_ omakase?"
  },
  {
    "id": 2,
    "body": "I for one welcome our new omakase overlords"
  },
  {
    "id": 3,
    "body": "Put me on the fast track to a delicious dinner"
  }]
}

是否可以从strongloop返回这种JSON格式?

1 个答案:

答案 0 :(得分:0)

默认情况下,开箱即用的restful api端点会返回看起来更像的内容:

{
    "id": 1,
    "title": "Node is not omakase",
    "comments": [
      {
        "id": 1,
        "body": "But is it _lightweight_ omakase?"
      },
      {
        "id": 2,
       "body": "I for one welcome our new omakase overlords"
      },
      {
        "id": 3,
        "body": "Put me on the fast track to a delicious dinner"
      }
    ]
}

但您可以使用remote methods执行相同的工作,然后按照您希望的方式按下数据。 http://docs.strongloop.com/display/public/LB/Remote+methods