Try: return response.json(yourjson) Em 03/11/2013 08:13, "Ricardo Pedroso" <rmdpedr...@gmail.com> escreveu:
> > Try change the response content-type, see below: > > > On Sun, Nov 3, 2013 at 6:28 AM, Mihir Lade <lade.mi...@gmail.com> wrote: > >> hi, >> >> i have a function in a controller which queries the database if the user >> is logged in and then grabs the information using json (as below) >> >> def pruchaseHistoryJson(): >> if auth.user: >> rows = db(db.sale.auth_id == auth.user.id >> ).select(db.sale.title, >> db.sale.price, >> db.sale.shipping_address, >> db.sale.shipping_state, >> db.sale.shipping_city, >> db.sale.shipping_zip_code) >> else: >> redirect(URL('default', 'user/login')) >> >> > > response.headers['Content-Type'] = 'application/json' > > > > >> import gluon.contrib.simplejson as json >> prodHistory = json.dumps([{'name': i.title, >> 'prodValue':i.price, >> 'shipAdd':i.shipping_address, >> 'shipCity':i.shipping_city, >> 'shipState':i.shipping_state, >> 'shipCode':i.shipping_zip_code} for i in >> rows]) >> return prodHistory >> >> > Also note that json top level arrays are not recommended: > > http://haacked.com/archive/2009/06/25/json-hijacking.aspx > > http://security.stackexchange.com/questions/7001/how-should-web-app-developers-defend-against-json-hijacking > > -- > 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/groups/opt_out. > -- 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/groups/opt_out.