0
我在Rails 3中編寫了一個API供iOS應用讀取。作爲字典的Rails JSON
我寫了這個:
def index
@shops = Shop.all
render json: @shops
end
輸出出來作爲一個磁盤陣列:
[{
"created_at": "2012-07-28T10:35:38Z",
"id": 1,
"name": "Shop1",
"phone": "111-111-1111",
"updated_at": "2012-07-28T10:35:38Z"
}]
不過,我想我的iOS應用程序讀取它作爲一個字典
哪有我把JSON輸出轉換成字典?
您想要什麼樣的結果?它應該是像「{」shops「:[{」created_at「:...}]}這樣的字典,或者其他不同的東西? – Veraticus 2012-08-16 15:06:11
是的,完全是這樣的字典。 – Castielle 2012-08-16 15:06:52