You have two options:
1) do the serializaion explicitely in the controller
from gluon.serializers import json
2) use routes to map the urls. Something like
routes_in=[('/app/$resource.json','/app/default/action.json/
$resource')]
On 2 Lug, 18:39, sethford <[email protected]> wrote:
> Yeah I realized that's how web2py works, I was under the impression
> that the extension always came after the args and directly before any
> variables. I tried changing the parser and realized I was going to get
> into all sorts of trouble with how urls are interpreted. I'm realizing
> more and more that web2py was not built to make using a REST interface
> very easy but am still trying to find ways to make it work. When
> requesting a specific resource in REST you generally have a path:
>
> /app/collection/some_resource#.ext
>
> and since you can't very well have a dynamic resource# as an action
> within a controller you end up using an action for the collection and
> parsing out the resource number. This worked just fine till i started
> appending the .json extension for the android since it doesn't see it
> and won't redirect to the json representation of the resource. I know
> I can just parse it out in the controller and make it work but it
> would be really ugly, is there another workaround that would allow me
> to let web2py do its thing but still be able to append an extension
> after the resource number? I'll probably check out the routes_in stuff
> next to see if there's a way of changing the url once it arrives to
> match with what web2py wants, but haven't played with that at all yet
> so any pointers would be great.
>
> On Jul 2, 4:54 pm, mdipierro <[email protected]> wrote:
>
> > Make sure you use
>
> > /app/controller/action.json/arg0/arg1/arg2
>
> > and not
>
> > /app/controller/action/arg0/arg1/arg2.json
>
> > On 2 Lug, 13:49, sethford <[email protected]> wrote:
>
> > > So I'm making an app that will be communicating with an android app in
> > > a RESTful way using json. For example the app has many todo lists
> > > which are retrieved with a url such as app/todo/lists/9.json (for list
> > > 9). For some reason when the request is parsed it doesn't recognize
> > > the .json as an extension and instead it ends up with an arg
> > > ['9.json'] and the extension defaults to html. I'm trying to figure
> > > out where this happens so I can fix it but it seems like something
> > > that shouldn't be happening at all.