DAL Rows objects are not json serializable. It must be converted to a
list of dict first as below:
@service.json
@service.jsonrpc
def list_users():
return dict(users=db(db.auth_user.id>0).select().as_list())
On Sep 10, 8:28 am, Manoj <[email protected]> wrote:
> Hello,
> I have following code in my controller
>
> @service.json
> @service.jsonrpc
> def list_users():
> return dict(users=db(db.auth_user.id>0).select())
>
> when i go tohttp://127.0.0.1:8000/userapp/default/list_users.json
>
> it gives me "no json"
>
> http://127.0.0.1:8000/userapp/default/list_users.xml
> works fine
>
> Is there any way to get json out of database rows? or do i need to
> create a list or dict first and then serialize it with simplejson ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---