0
我有另一個Rails應用程序提供RESTful JSON API。我可以通過下面的curl請求測試響應(您也可以看到它返回的第一個項目的示例)。來自RESTful api的Rails json請求如何呈現視圖
我可以弄清楚如何從較大的響應中提取某些項目。我只是不確定我應該如何在Rails應用程序上提供響應,以便將其呈現給客戶端。
我假設我需要保存這是在某種類。我可以使用捲曲嗎?我用鐵軌很綠,並且非常讚賞任何幫助。
謝謝!
curl "http://api.foobar.com/stuff/stuff_name/catalog_items.json" -H "X-Api-Key: georgesbush"
它返回一組很好的JSON數據。
{
"data": {
"catalog_items": [
{
"current_price": "9999.0",
"close_date": "2013-05-14T16:08:00-04:00",
"open_date": "2013-04-24T11:00:00-04:00",
"stuff_count": 82,
"minimum_price": "590000.0",
"id": 337478,
"estimated_price": "50000.0",
"name": "This is a really cool name",
"current_winner_id": 696969,
"images": [
{
"thumb_url": "http://foobar.com/images/93695/thumb.png?1365714300",
"detail_url": "http://foobar.com/images/93695/detail.png?1365714300",
"position": 1
},
{
"thumb_url": "http://foobar.com/images/95090/thumb.jpg?1366813823",
"detail_url": "http://foobar.com/images/95090/detail.jpg?1366813823",
"position": 2
}
]
}
]
},
"pagination": {
"per_page": 1,
"page": 1,
"total_pages": 131,
"total_objects": 131
}
}
如果您使用的框架,如骨幹,你可以直接使用這個輸出和渲染您的客戶端上的意見。 – davogones 2013-04-27 06:37:18
不幸的是,兩側的導軌:-( – jahrichie 2013-04-27 19:06:56