From your email below, it looks like you are returning one "post" object and 
them returning the to-many array of related "comment" objects. So it is not 
just randomly different objects per se.

ERRest can do this today in a nested format by using ERXKeyFilter to include 
the toMany relationship. I think your best bet is to think how you would 
reformat the nested relationships into separate objects in the same response as 
shown in your example. It is the same data, just formatted differently.

The source code for ERRest is available to you, and yes, you have some digging 
into ERRest to do to get an understanding of how it works so that you can 
customize it to do what you want, but there is no reason why it is not possible 
even if you have to hack away to create a custom subclass of 
er.rest.routes.ERXRouteController to force it to generate the response exactly 
as you want.

There is no logic that will create the response format you want today because 
no one has written it. So, yes it will be some time and work to get it done 
unfortunately.


On Sep 19, 2013, at 8:07 PM, Michael Kondratov <[email protected]> 
wrote:

> I did that. But I am still unable to return two types of objects in the same 
> root node. I can only pass to (response method ) a single object or an array 
> of objects of the same type .
> 
> Sent from my iPhone
> 
> On Sep 19, 2013, at 14:51, Kieran Kelleher <[email protected]> wrote:
> 
>> One solution might be to create  a custom er.rest.format.IERXRestWriter 
>> implementation and register a new format for ember js in 
>> er.rest.format.ERXRestFormat static block where it calls 
>> ERXRestFormat.registerFormatNamed repeatedly to provide customized API for 
>> different types of clients.
>> 
>> 
>> On Sep 19, 2013, at 2:22 PM, Michael Kondratov <[email protected]> 
>> wrote:
>> 
>>> Hello,
>>>     I am working on an Ember.js connector for ERRest. Everything is working 
>>> beautifully, except embedded relationships. I can't figure out how to 
>>> generate this style of JSON:
>>> 
>>> 
>>> {
>>>   "post": {
>>>     "id": 1
>>>     "title": "Rails is omakase",
>>>     "comments": ["1", "2"],
>>>     "_links": {
>>>       "user": "/people/dhh"
>>>     },
>>>   },
>>> 
>>>   "comments": [{
>>>     "id": "1",
>>>     "body": "Rails is unagi"
>>>   }, {
>>>     "id": "2",
>>>     "body": "Omakase O_o"
>>>   }]
>>> }
>>> 
>>> Any pointers?
>>> 
>>> 
>>> 
>>> Michael Kondratov
>>> Aspire Auctions, Inc.
>>> 216-231-5515
>>> 
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list      ([email protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/kelleherk%40gmail.com
>>> 
>>> This email sent to [email protected]
>> 

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to