出于某种原因,我的控制器创建的任何 json 都会生成一个 json 数组,但不会生成一个对象。我想知道它的行为是否正常?如果它我怎么能得到我正在寻找的东西。
这里的控制器
def index
@articles = Article.all
respond_to do |format|
format.json { render :json => @events }
end
end
现在在这里我实际上得到了什么
[{"allday":true,"created_at":"2013-01-10T23:49:19Z","customer_id":1,"description":"A meeting tomorrow between Prime Minister","id":35}]
现在但是我想先看看这个对象,就像标准 json 一样
{ "Article":{"allday":true,"created_at":"2013-01-10T23:49:19Z","customer_id":1,"description":"A meeting tomorrow between Prime Minister","id":35}}