]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - lib/CGI/Ex/Conf.pm
CGI::Ex 2.37
[chaz/p5-CGI-Ex] / lib / CGI / Ex / Conf.pm
index 1288e7b735a1f30fb37880a32c4f31f66bd230f6..0fdb2f165d9258411d6db0be416c23f556e4f440 100644 (file)
@@ -7,7 +7,7 @@ CGI::Ex::Conf - Conf Reader/Writer for many different data format types
 =cut
 
 ###----------------------------------------------------------------###
-#  Copyright 2007 - Paul Seamons                                     #
+#  Copyright 2003-2012 - Paul Seamons                                #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -29,7 +29,7 @@ use vars qw($VERSION
             );
 @EXPORT_OK = qw(conf_read conf_write in_cache);
 
-$VERSION = '2.24';
+$VERSION = '2.37';
 
 $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;
This page took 0.021938 seconds and 4 git commands to generate.