[pm-h] JSON Dates and DateTime

Mark Allen mrallen1 at yahoo.com
Thu Feb 13 15:55:38 PST 2014


You should subclass DateTime into your own package

package My::DateTime;
use base ('DateTime');

sub TO_JSON { ...; }

Then bless your objects into My::DateTime

Probably errors since I'm typing on my phone but you get the gist.

Mark

Sent from my iPhone

> On Feb 13, 2014, at 4:58 PM, "Michael R. Davis" <mrdvt92 at yahoo.com> wrote:
> 
> Mark et al,
>  
> >> I need to call a JSON web service with dates.  ...  '/Date(1392233750000-0600)/'
> > As far as I am aware, JSON supports auto-serialization of a blessed object only if allow_blessed => 1 and convert_blessed => 1.
>  
> I'll look into that... It looks like I'll need to add a TO_JSON method to the DateTime object (which I'm not exactly sure how to do...)
>  
> Just to make things harder.  Since the remote service requires sort_by and performance of JSON::PP is so SLOW.  I'm using JSON::PP to encode and JSON::XS to decode.  It's crazy the things we have to do to get around implementations in the first place.
> Thanks,
> Mike
>    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/mailman/private/houston/attachments/20140213/7d847bf9/attachment.html>


More information about the Houston mailing list