On Jun 13, 1:00 pm, NickFranceschina <[email protected]>
wrote:
> anyone?
>
> On Jun 12, 4:52 pm, NickFranceschina <[email protected]>
> wrote:
>
>
>
> > if I have a records collection (of type Rows) from a select() call
> > through the DAL...  why is the output different between these two
> > versions ofjsonconversion?
>
> > >>> records.json()

this is implemented in gluon/dal.py as part of the Rows object, so
records.json()  returns the json representation for a row (therefore
you don't have / see the index);

>
> > '[{"description": "my description", "created_by": 1, "id": 1,
> > "created_on": "2010-06-06 23:21:52", "name": "my name"},
> > {"description": "moms community", "created_by": null, "id": 2,
> > "created_on": "2010-06-11 19:54:06", "name": "mom"}, {"description":
> > "dads community", "created_by": null, "id": 5, "created_on":
> > "2010-06-11 20:18:41", "name": "dad"}, {"description": "dads
> > community", "created_by": null, "id": 6, "created_on": "2010-06-12
> > 16:28:19", "name": "dad"}]'
>
> > >>> from gluon.serializers importjson
> > >>>json(records)

if you look at gluon/serializers.py, you will see that json() is
simply a convenience for simplejson.dumps( item ) --- in this case, a
Set - so you have a json representation of the Set (complete with
id's).

>
> > '{"1": {"created_on": "2010-06-06 23:21:52", "description": "my
> > description", "name": "my name", "id": 1, "created_by": 1}, "2":
> > {"created_on": "2010-06-11 19:54:06", "description": "moms community",
> > "name": "mom", "id": 2}, "5": {"created_on": "2010-06-11 20:18:41",
> > "description": "dads community", "name": "dad", "id": 5}, "6":
> > {"created_on": "2010-06-12 16:28:19", "description": "dads community",
> > "name": "dad", "id": 6}}'
>
> > the former is what I would expect... a list of dictionaries...
>
> > the latter builds a dictionary of dictionaries...

Reply via email to