Apologies if I was not clear, when you do a cross join as in the example
you get Rows now, and your code is as I meant it was just a typo, my need
is to represent the record set into json object...it works well if there is
no join, but when another table comes in the picture the way to access
fields changes

db.table.field

So I want a rows to be represented as ['fieldname', 'field value],
['fieldname', 'field value], ['fieldname', 'field value], etc

It's easy with a single table but when your record set has fields from
another table it becomes a problem...this is my working iteration with
single table but joint does not apply:

def get_json(rs):
    json = "["
    for row in rd:
         json += "{"
         for key, value in (row.as_dict()).values:
             json +=  "'",key, "':'", value,"'"
        json += "},"
   json += "]"


On 14 Feb 2014 15:11, "Leonel Câmara" <leonelcam...@gmail.com> wrote:

> I'm not sure I'm understanding exactly what you're trying to do. You say
> you want to display the value of the foreign key (which would be an
> integer) but in your code you seem to be only interested in the names. So
> this may or may not be what you want.
>
> I've found a bug here
>
> rs = db(db.owner.id==db.dog.owner).select(db.owner.name, db.owner.name)
>
> This should be:
>
> rs = db(db.owner.id==db.dog.owner).select(db.owner.name, 
> db.dog.name<http://db.owner.name/>
> )
>
> Then you can do:
>
> for r in rs:
>     print r.owner.name + ' : ' + r.dog.name
>
>
>  --
> 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.

Reply via email to