[pm-h] JSON vs JSON::PP vs JSON:XS between EL5 and EL6

Michael R. Davis mrdvt92 at yahoo.com
Sun Apr 19 21:27:25 PDT 2015


Reini,I added the TO_JSON_WITH_TYPE API to my JSON fork on Github.  Let me know what you think.  I like this API much better than the TO_JSON API.  It supports BOOLEAN out of the box as well. It's just a better all around API.  I coded it so if the object has both TO_JSON and TO_JSON_WITH_TYPE the "with type" method will be selected first so we can have backwards compatibility too.Thanks,Mike https://github.com/makamaka/JSON/compare/master...mrdvt92:master perl -e '
use strict;
use warnings;
use blib;
BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; }
use JSON;
use Data::Dumper qw{Dumper};use Hash::Ordered qw{};
sub Hash::Ordered::TO_JSON_WITH_TYPE {HASH=>[shift->as_list]};
my $oh=Hash::Ordered->new(a => 1, b=>2, c=>3, d=>4, e=>5);
#print Dumper($oh);
#print join(",", @{$oh->TO_JSON_WITH_TYPE()}), "\n";my $coder = JSON->new->allow_blessed->convert_blessed;
print $coder->encode({myhash=>$oh}), "\n";
' {"myhash":{"a":1,"b":2,"c":3,"d":4,"e":5}}


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/houston/attachments/20150420/d962be7f/attachment.html>


More information about the Houston mailing list