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" <[email protected]> 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
>
_______________________________________________
Houston mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/