yes you are right .as_list() will be called automatically when pass it to 
response.json()

rows.as_json() work well too unfortunately it's not documented in book yet:
def json_rows_as_json():
query = (db.auth_user.id > 0)
rows = db(query).select()
return rows.as_json()

*not sure about :*
@request.restful, you don't even have to call response.json -- if you make 
an 'application/json' request, the result will automatically be converted 
to JSON.
*code:*
@request.restful()
def restful_json_rows_as_list():
response.view = 'generic.json'
def GET():
query = (db.auth_user.id > 0)
rows = db(query).select()
return rows
return locals()

*url:*
http://127.0.0.1:8000/test/api/restful_json_rows_as_list.json

*result :*
<table><thead><tr><th>
...
</th></tr></thead></table>

different result with code that return json format:
@request.restful()
def restful_json_rows_as_list():
def GET():
query = (db.auth_user.id > 0)
rows = db(query).select()
return response.json(rows)
return locals()

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to