我有一个rails4应用程序。 @events来自db,@results来自第三方API。我想摆脱根并发送它,因为两个都是相同的来源,就像我在下面显示的代码一样。
我该怎么做?
除此之外,当你看到freebusy被嵌入到事件中时,我不知道为什么因为它们似乎在控制器中分离。可以告诉我为什么会这样吗?
控制器
{"events":[{"id":18,"recipientId":2,"recipientName":"Sean Hungarian","senderId":1,
"senderName":"Szilard Magyar","title":"das;fk;aslf","description":"",
"start":"Wed, 16 Dec 2015 00:00:00 +0000","end":"Wed, 16 Dec 2015 02:00:00 +0000","allDay":false,
"recurring":false}], "freebusy":[{"start":"2015-12-31T03:30:00Z","end":"2015-12-31T04:30:00Z","title":"busy","editable":false}]}
当前的json
[{"id":18,"recipientId":2,"recipientName":"Sean Hungarian","senderId":1,"senderName":"Szilard Magyar",
"title":"das;fk;aslf","description":"","start":"Wed, 16 Dec 2015 00:00:00 +0000","end":"Wed, 16 Dec 2015 02:00:00 +0000",
"allDay":false,"recurring":false}, {"start":"2015-12-31T03:30:00Z","end":"2015-12-31T04:30:00Z",
"title":"busy","editable":false}]
期望的json
face866
答案 0 :(得分:1)
尝试,
format.json { render json: [@events, @results]}
但是,这是json的好格式吗?