Answering my own question: No idea if this works generally, but it's adequate for my case.
In my ERXRouteController subclass I strip the topmost wrapper node which is
generated as a null wrapper.
I'm almost positive I should be doing this more elegantly using
ERXRestFormat.Delegate formatDelegateForFormat(ERXRestFormat format)
but this works for me:
//Override for a request body object nested in an otherwise empty unnamed
container.
// Works for test case: curl -X POST -d "{'Person':{ name:'Andrew Schrag' }}"
http://localhost:62092/cgi-bin/WebObjects/RESTExample.woa/ra/Person.json
@Override
public ERXRestRequestNode requestNode() {
ERXRestRequestNode node = super.requestNode();
if (node.name() == null && node.childAtIndex(0) != null) {
node = node.childAtIndex(0);
}
return node;
}
Charles Young
NEURAL GLUE
503.360.3178
[email protected]
neuralglue.com
On Aug 30, 2013, at 10:48 PM, Charles Young <[email protected]> wrote:
> Hi Paul,
>
> The setting makes no difference that I can see.
>
> Please note though, the code behaves correctly for the route and filters as
> it is configured. My issue is that I am wrapping the payload in an unexpected
> way. It is expecting the person attributes directly, I am wrapping the
> attributes in extra JSON.
>
> This means that when it expects to have the attributes as the children in an
> ERXRequestNode, it instead has them wrapped inside an otherwise empty
> ERXRequestNode.
>
> Perhaps what I should be doing is to create an otherwise empty entity
> containing a relationship named Person and use that to unwrap the nesting. I
> shall try that tomorrow.
>
> Any other ideas would be most appreciated.
>
> Cheers,
> Charles
>
>
> On Aug 30, 2013, at 9:16 PM, Paul Yu <[email protected]> wrote:
>
>> Does the Property
>>
>>
>> # No type in the JSON
>> ERXRest.writeTypeKey=true
>>
>> work?
>>
>> Paul
>> On Aug 30, 2013, at 11:05 PM, Charles Young <[email protected]> wrote:
>>
>>> Hi Amedeo,
>>>
>>> No - or at least I don't believe so. I'm using the vanilla
>>> ERRestRouteExample project as a testbed.
>>>
>>> Cheers,
>>> Charles
>>>
>>>
>>>
>>> On Aug 30, 2013, at 4:45 PM, Amedeo Mantica <[email protected]> wrote:
>>>
>>>> Are u using extjs ?
>>>>
>>>> Amedeo
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On 31/ago/2013, at 00:36, Charles Young <[email protected]> wrote:
>>>>
>>>>> Hi All,
>>>>>
>>>>> I have an API that I'm trying to recreate using Webobjects. The service
>>>>> communicates using nested JSON.
>>>>>
>>>>> So Instead of using:
>>>>> curl -X POST -d "{ name:'Andrew Schrag' }"
>>>>> http://localhost:62092/cgi-bin/WebObjects/RESTExample.woa/ra/Person.json
>>>>>
>>>>> It expects something like:
>>>>> curl -X POST -d "{'Person':{ name:'Andrew Schrag' }}"
>>>>> http://localhost:62092/cgi-bin/WebObjects/RESTExample.woa/ra/Person.json
>>>>>
>>>>> Is there some simple way of creating an ERXRoute or an ERXKeyFIlter that
>>>>> will describe the nesting, or should I be looking at providing my own
>>>>> updateObjectWithFilter method that will assume a nested level.
>>>>>
>>>>> Thanks for any hints.
>>>>>
>>>>>
>>>>> Cheers,
>>>>> Charles
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> 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/amedeomantica%40me.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/pyu%40mac.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/charles%40neuralglue.com
>
> This email sent to [email protected]
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ 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]
