Hello all, Massimo, I tried the same, I saved request.vars.input into a file and tried:from a python console:imported json and json.loads worked fine. You nailed the problem: I imported the wrong json module:
I changed the imports from: *from gluon.serializers import json* to: *from gluon.contrib import simplejson* and the problem was solved. I assumed that the json from gluon.serializers would have the loads/dumps method. My mistake. It seemed like the obvious import to do. If I had check the methods, I would have seen that there was no loads/dumps method available..Richard mentioned simplejson in the thread and that made me test simplejson import instead. Thanks all for help and ideas! It is awesome to get such a group of experts coming out to help :) Best, Clara . El viernes, 20 de febrero de 2015, 15:19:55 (UTC-3), clara escribió: > > Hello, > > I am making an Ajax call and calling a controller with the json data I > need to process in the controller. > > The problem I am having (and I am sure the answer will be simple and I > will hate myself for the silly question ) is that if I select > request.vars.input, its value is not a json object anymore so a loads > method will fail. It is a string object and if I try to eval(it) I get an > error. So even when the data is right there I can not use it in the > controller. > Any ideas will be more than welcome! > > (The controller and its print outs are shown bellow.) > > Thanks, > Clara > > def test(): > print "test called" > print "test called" > print 'request.vars' > print request.vars > print 'request.vars.input' > > Here is what the controller prints out: > > test called > request.vars > <Storage {'input': '[{"the_owner":1,"category":1,"name":"La marcha del > oro","price":44.45,"id":1,"quantity":100},{"the_owner":3,"c > ategory":3,"name":"Toy > Story","price":34.56,"id":2,"quantity":23},{"the_owner":2,"category":2,"name":"La > > Sirenita","price":56.67," > > id":3,"quantity":10},{"the_owner":null,"category":null,"name":null,"price":null,"id":null,"quantity":null}]'}> > request.vars.input > [{"the_owner":1,"category":1,"name":"La marcha del > oro","price":44.45,"id":1,"quantity":100},{"the_owner":3,"category":3,"name":"T > oy > Story","price":34.56,"id":2,"quantity":23},{"the_owner":2,"category":2,"name":"La > > Sirenita","price":56.67,"id":3,"quantity":10} > > ,{"the_owner":null,"category":null,"name":null,"price":null,"id":null,"quantity":null}] > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.