In web2py have how you get each fields, at moment that you recover the 
data, stop here, and adding as_list() , most linkely will return all list 
as list:

rows = db(query).select(db.account.product.name, db.account.
subscription_amount, orderby = ~db.account.id).as_list()

And return this result as json :

return response.json(rows)

I think that work well

Em sexta-feira, 7 de outubro de 2016 09:59:09 UTC-3, 黄祥 escreveu:
>
> thanks for your hints, Marlysson, but the format is not same like 
> highcharts needs
> *format needed :*
> data: *[ *
> * ['Dana Ekuitas', 1.0 ],*
> * ['Dana Likuid', 2.0 ],*
> * ['Dana Lancar', 3.0 ],*
> *]*
>
>
> *my code :controllers/default.py*
> @service.json
> def my_data():
>     query = (db.account.investor == 1)
>     rows = db(query).select(db.account.product.name, 
> db.account.subscription_amount, orderby = ~db.account.id)
>     #return json.dumps([[r.product.name, r.subscription_amount] for r in 
> rows] ) *# not worked no error occured because it's return string*
>     #return response.json([[r.product, r.subscription_amount] for r in 
> rows] ) *# not worked error traceback : raise AttributeError*
>
>     #your_data = rows.as_dict()
>     #your_data = rows.first().as_dict()
>     your_data = rows.as_list()
>     return response.json(your_data) *# not worked the format it's not 
> expected must been in bracket [ [] ] like in format needed above*
>
> any idea how to achieve it using web2py way?
>
> thanks and best regards,
> stifan
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to