> > I trying to send un object from a view to controller (Web2py) in the same > way that: >
If you go to the ticket system in <test app>/appadmin, you'll probably see a ticket with this error: TypeError: expected a character buffer object That's because the file object cannot write Python objects directly, they should be converted first to strings or other suported type. The request.body.read() method already returns the string with the data sent by the client request, so, there's no need to convert the JSON data to a Python object server-side, unless you want to process it besides storing it in a file. If you want to read the json data sent from reques.vars.data you could use this: In the controller: def jsontest(): print "request.vars", request.vars # store the data as file import os with open(os.join(request.folder, "static", "myfile.txt"), "w") asmyfile myfile.write(request.vars.data) raise HTTP(200, "If I said you had a beautiful body, would you hold it against me? I...I am no longer infected.") In the view: {{=SCRIPT(""" jQuery(document).ready(function(){ $.post("%(url)s", {data: <here goes the JSON string>}, function(data){window.alert(data);}); }); """ % dict(url=URL("default", "jsontest.json")))}} By the way, for storing JSON data server-side, there's a new feature in trunk that supports "json" field types, an IS_JSON validator and a json form widget --