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

Robert Dobbs bobisdobbs at hotmail.com
Wed Sep 20 02:11:59 CEST 2006


>From: "Nilson Santos Figueiredo Junior" <acid06 at gmail.com>
>Date: Tue, 19 Sep 2006 20:18:21 -0300
>
>On 9/18/06, Robert Dobbs <bobisdobbs at hotmail.com> wrote:
> > 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.
>
>That's something I couldn't figure out how to do, although I tried. I
>think it's something not possible to be done using JSON::Syck so I
>might try the plain old pure perl JSON.
>
> > 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.
>
>The problem with this approach is that your JS code will need to know
>about your backend's date format. Kind of messy.

Well, if you could specify your own json_inflate and json_deflate subrefs to 
override the default inflate/deflate which would be used for the dump, at 
least you could control it.  For example, you could have your module always 
spit the date into ISO for JSON to be parsed out by your javascript 
functions.  Then if you changed your DB backend you wouldn't have to rewrite 
your javascript.

Mark

_________________________________________________________________
Share your special moments by uploading 500 photos per month to 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