Nice!

Looking for loads_json in serializers.py; Found custom_json instead that 
takes an object, checks it for a custom attribute and a callable. then 
returns the objects custom_json() method...[I call it a method but in 
Python I guess it's an attribute?]...Basically, before calling json() I 
need to decide if I want to override the .default() call or subclass 
JSONEncoder and set session.vars._default_encoder to my subclass.

I'll give the spreadsheet a try as well. So I can avoid the gluon xml code 
being displayed.

Thank you..

Reading the docs and taking notes left them here for searchable reference:
custom_json is a parameter to json() that calls json_parser.dumps...where 
json_parser is either json or simplejson imported
custom_json gets assigned to the defualt parameter in dumps
dumps is found in __init__.py (nice documnetation) and returns the 
JSONEncoder that calls dumps()
notes say; "   ``default(obj)`` is a function that should return a 
serializable version
    of obj or raise TypeError. The default simply raises TypeError.






So dumps takes several arguments that are not available if you use the 








On Monday, January 21, 2013 5:20:33 AM UTC-6, Alan Etkin wrote:
>
> > For me, a 'json:reference attributes' field would basically be like a 
> "list: string" field but with only one string
> > holding a json object of a variable list of attributes with their value 
> and unit.
>
> Then you can do simply:
>
> db.define_table(... Field("a_list_of_json_objects", "json"))
>
> When you get the db record, it is represented as Python object for 
> server-side processing. If you stored a json object, then you get a Python 
> dict
>
> For explicit json export do <Rows/Row object>.as_json()
>
> > So the enhancement would: use a select widget ...
>
> It seems to me that you could build a custom widget and assign it to the 
> json field.
>
> > have the ability to assign a grid object for viewing rows where the 
> column names match the fields in the referenced table
>
> Also consider using contrib.spreadsheet and the data argument (for editing 
> a db)
>
> BTW, if you need to do custom deserialize/serialize of json, you can do:
>
> from serializers import loads_json, json
>
>
>
>

-- 



Reply via email to