i do a lot of: post_data = json.loads(request.body.read()) ... return json.dumps(retval)
works nicely for me. :) On Sunday, November 18, 2012 10:09:15 PM UTC-8, Jonathan Lundell wrote: > > On 18 Nov 2012, at 9:54 PM, Jason Brower <enco...@gmail.com <javascript:>> > wrote: > > I still don't get it. To me it looks like @service.json is all about > taking data in the URL parameters and turning it into json code. I am > wanting to build the server to receive much more data than could ever be > including in that URL. Or am I missing something in the documentation. > http://web2py.com/books/default/chapter/29/10#Remote-procedure-calls > I want the server to TAKE json data and then RETURN json data. > > > service.json passes URL parameters to the specified method in your > controller, which has to do its own parsing of the POST body. This is how > the service.jsonrpc handler does it: > > data = json.loads(request.body.read()) > > Your controller method needs to do that, too. If you don't want to use any > of the URL parameters, you don't need to. > > Alternatively you could forget about Service altogether, and just do all > the JSON stuff in your controller. > > > On 11/19/2012 07:43 AM, Jonathan Lundell wrote: > > On 18 Nov 2012, at 9:14 PM, encompass <enco...@gmail.com <javascript:>> > wrote: > > Let's say for example I have the example code from the json website: > > { > "glossary": { > "title": "example glossary", > "GlossDiv": { > "title": "S", > "GlossList": { > "GlossEntry": { > "ID": "SGML", > "SortAs": "SGML", > "GlossTerm": "Standard Generalized > Markup Language", > "Acronym": "SGML", > "Abbrev": "ISO 8879:1986", > "GlossDef": { > "para": "A meta-markup language, used to create > markup languages such as DocBook.", > "GlossSeeAlso": ["GML", "XML"] > }, > "GlossSee": "markup" > } > } > } > } > } > And let's assume this is sent data from the phone. > How would I build the controller to part this? The example here from the > book didn't tell me much. At least that I can see. > > > JSON-RPC requires that the top-level JSON object be in a certain format, > with specified members, and the return object is similarly defineds. Unless > you want to redefine your JSON objects, you can't use JSON-RPC. > > There's a JSON service as well, but you have to do your own parsing. You > can look at gluon.utils.Service.serve_jsonrpc to see how the JSON-RPC > service does it. I'm not sure why the JSON service doesn't decode the > incoming object, but there you are... > > > > :/ @service.jsonrpc > def getTasks(): > todos = db(db.todo).select() > return [(todo.task,todo.id) for todo in todos] > > > > On Monday, November 19, 2012 7:05:49 AM UTC+2, encompass wrote: >> >> The application on the mobile devices already exists and works. I need >> to make many applications that work with the applications for testing and >> so forth. >> The application currently sends the JSON data to a webserver so I just >> want to make web2py the server instead of the "other framework". >> >> >> On Sunday, November 18, 2012 7:48:02 AM UTC+2, Marin Pranjić wrote: >>> >>> JSONRPC should be used if you want to implement RPC service but if you >>> only need to send json data, you can do it that way or another. >>> >>> How would you send the data? Something that works in the background or >>> manually, from web browser? >>> >>> Anyway, the issue can be how to do it on your mobile device (depends >>> or your needs), not the web2py as a server :) >>> >>> >>> On Sun, Nov 18, 2012 at 6:06 AM, Jason Brower <enco...@gmail.com>wrote: >>> >>>> I have a mobile device that sends various data using json to a server. >>>> I would like this server to be web2py. >>>> How would I do this? >>>> Am I on the right track here? >>>> http://web2py.com/books/default/chapter/29/10#JSONRPC >>>> Or am I looking in the wrong place. >>>> There will be a large amount of data sent. >>>> BR, >>>> Jason Brower >>> >>> > > > -- > > > > > > > -- > > > > > > > --