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

Michael R. Davis mrdvt92 at yahoo.com
Mon Mar 30 10:39:34 PDT 2015


Houston PMs,I have a catch 22 that I cannot figure out.  I need both JSON::PP (for sort_by capability on encoding) and JSON::XS (for performance on decoding).  We are moving from EL5 to EL6 but the JSON libs are not really consistent between the environments.  Has anyone else worked through this fiasco and have any best practices on how to get past this?Thanks,Mike #use JSON perl version for sort_by for interoperability with crappy Windows service$self->json->sort_by(sub {no warnings q{uninitialized};$sorter->{$JSON::PP::a} <=> $sorter->{$JSON::PP::b}});$self->json->encode($data_input); #use JSON:XS version for performance with VERY large returnsreturn $self->jsonxs->decode($json_return); So, it looks like I need to do something like this. if ('some logic to figure out running on EL5 vs EL6 like load JSON and see if JSON->can("sort_by")') {use JSON::PP qw{}; #we require JSON::PP->sort_by
} else {use JSON qw{}; #we require JSON::PP->sort_by
} mrdvt92
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/houston/attachments/20150330/e3bf424c/attachment.html>


More information about the Houston mailing list