X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FCGI%2FEx%2FConf.pm;h=04ff2a33ce71b7b413dbfa71af12bdc33a1be5ed;hb=fdecaac30a1168ed894c46d61b6c95524ec62a4e;hp=365ece2d057b1fbd4640364a1502aea478e5e6d0;hpb=490b94ab4051adf93abf16a4ed34efb923d6e8fc;p=chaz%2Fp5-CGI-Ex diff --git a/lib/CGI/Ex/Conf.pm b/lib/CGI/Ex/Conf.pm index 365ece2..04ff2a3 100644 --- a/lib/CGI/Ex/Conf.pm +++ b/lib/CGI/Ex/Conf.pm @@ -29,7 +29,7 @@ use vars qw($VERSION ); @EXPORT_OK = qw(conf_read conf_write in_cache); -$VERSION = '2.22'; +$VERSION = '2.32'; $DEFAULT_EXT = 'conf'; @@ -263,7 +263,8 @@ sub read_handler_json { CORE::read(IN, my $text, -s $file); close IN; require JSON; - return scalar JSON::jsonToObj($text); + my $decode = JSON->VERSION > 1.98 ? 'decode' : 'jsonToObj'; + return scalar JSON->new->$decode($text); } sub read_handler_storable { @@ -545,7 +546,15 @@ sub write_handler_json { my $file = shift; my $ref = shift; require JSON; - my $str = JSON::objToJson($ref, {pretty => 1, indent => 2}); + my $str; + if (JSON->VERSION > 1.98) { + my $j = JSON->new; + $j->canonical(1); + $j->pretty; + $str = $j->encode($ref); + } else { + $str = JSON->new->objToJSon($ref, {pretty => 1, indent => 2}); + } local *OUT; open (OUT, ">$file") || die $!; print OUT $str;