[Dbix-class] RFC: DBIx::Class::JSON

Robert Dobbs bobisdobbs at hotmail.com
Mon Sep 18 19:45:47 CEST 2006


>From: "Nilson Santos Figueiredo Junior" <acid06 at gmail.com>
>Date: Fri, 15 Sep 2006 20:46:49 -0300
>
>On 9/15/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
> > I think what I'd like to see is a general serialization interface that 
>plugins
> > can be written for. Something like
> >
>
>Looks good. The main problem I think is how to properly serialize
>everything (e.g. DateTime objects). Also, how'd you restrict what
>fields would be serialized or not?

If the field already has inflate/deflate, why not deflate it before storage 
in the serialized construct?  So the DateTime object attached to your $foo 
will become the terse database value instead of page after page of DateTime 
dump.  And when de-serialized, it runs all fields of the class through any 
available inflators.

Or, if another set of 'flators could be specified for a field, would it be 
possible to build a Javascript Date object into the JSON construct, for 
example?  Some way to put in a javascript eval literal "new Date( 
".join(',', map $dt->$_, qw( year month day hours minute second millisecond 
) )." ); ";   # ... or something.

Hrmm, well maybe it is easier to keep the terse deflated value in the JSON 
thing, and in your Javascript application you could write functions to throw 
your objects through that inflate them back into Javascript objects of other 
types.

But then you've got to do JS pattern matches and it could be easier when you 
start with the inflated object on the perl side.

Mark

_________________________________________________________________
Add fun gadgets and colorful themes to express yourself on Windows Live 
Spaces   
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://www.get.live.com/spaces/features




More information about the Dbix-class mailing list