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

Michael R. Davis mrdvt92 at yahoo.com
Mon Apr 13 20:51:29 PDT 2015


> From: Reini Urban rurban at x-ray.at
> First: Switch to ... Cpanel::JSON::XS
> The developer (me) is usually very responsive and it sounds 
> like a worthwhile feature. Reini,
I was looking into this and it seems like we could add another function search like TO_JSON. I’d like to recommend supporting TO_JSON_WITH_TYPE that would return a value like (HASH=>[a=>1, b=>2, c=>3]) or (BOOLEAN=>"Perl true") we might want to include the nominal ARRAY and SCALAR cases to round out the API.   Here's an example with Hash::Ordered that would give me what I need. 
perl -e '
use strict;
use warnings;
use Data::Dumper qw{Dumper};
use Hash::Ordered qw{};
*Hash::Ordered::TO_JSON_WITH_TYPE=sub {HASH=>shift->as_list};
use Cpanel::JSON::XS qw{};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 = Cpanel::JSON::XS->new->allow_blessed->convert_blessed;
print $coder->encode({hash=>$oh}), "\n";
'
 What do you think?
Mike mrdvt92
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/houston/attachments/20150414/ae76f473/attachment.html>


More information about the Houston mailing list