From: Dagfinn Ilmari Mannsåker Date: Tue, 4 Dec 2012 15:57:12 +0000 (+0000) Subject: Create a JSON::Any object, so setting $ENV{JSON_ANY_CONFIG} works. X-Git-Tag: 0.32~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0edcbfee41be71fffd06f32db5c86574e156c29a;p=gitmo%2FMooseX-Storage.git Create a JSON::Any object, so setting $ENV{JSON_ANY_CONFIG} works. Adjust tests that were setting the wrong values and the default happened to work. --- diff --git a/Changes b/Changes index 2fbc887..62f095b 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,8 @@ Revision history for MooseX-Storage * Change to use core Digest and Digest::SHA dists, rather than Digest::SHA1. RT##69811 + * Create a JSON::Any object, so setting $ENV{JSON_ANY_CONFIG} works. + Adjust tests that were setting the wrong values and the default happened to work. 0.31 * Add example for add_custom_type_handler to the MooseX::Storage::Engine docs. (perigrin) diff --git a/lib/MooseX/Storage/Format/JSON.pm b/lib/MooseX/Storage/Format/JSON.pm index 1863235..1a100da 100644 --- a/lib/MooseX/Storage/Format/JSON.pm +++ b/lib/MooseX/Storage/Format/JSON.pm @@ -16,12 +16,12 @@ requires 'unpack'; sub thaw { my ( $class, $json, @args ) = @_; utf8::encode($json) if utf8::is_utf8($json); - $class->unpack( JSON::Any->jsonToObj($json), @args ); + $class->unpack( JSON::Any->new->jsonToObj($json), @args ); } sub freeze { my ( $self, @args ) = @_; - my $json = JSON::Any->objToJson( $self->pack(@args) ); + my $json = JSON::Any->new->objToJson( $self->pack(@args) ); utf8::decode($json) if !utf8::is_utf8($json) and utf8::valid($json); # if it's valid utf8 mark it as such return $json; } diff --git a/t/011_basic_json_w_utf8.t b/t/011_basic_json_w_utf8.t index 64cef7c..dd4f370 100644 --- a/t/011_basic_json_w_utf8.t +++ b/t/011_basic_json_w_utf8.t @@ -18,7 +18,7 @@ BEGIN { # - SL BEGIN { $ENV{JSON_ANY_ORDER} = qw(XS); - $ENV{JSON_ANY_CONFIG} = "utf8=1"; + $ENV{JSON_ANY_CONFIG} = "utf8=0"; } plan tests => 16; diff --git a/t/104_io_w_utf8.t b/t/104_io_w_utf8.t index 5993f6d..efff519 100644 --- a/t/104_io_w_utf8.t +++ b/t/104_io_w_utf8.t @@ -21,7 +21,7 @@ BEGIN { # - SL BEGIN { $ENV{JSON_ANY_ORDER} = qw(XS); - $ENV{JSON_ANY_CONFIG} = "utf8=1"; + $ENV{JSON_ANY_CONFIG} = "utf8=0"; } plan tests => 8; use_ok('MooseX::Storage'); diff --git a/t/105_io_atomic_w_utf8.t b/t/105_io_atomic_w_utf8.t index 1c88be2..8aec7b4 100644 --- a/t/105_io_atomic_w_utf8.t +++ b/t/105_io_atomic_w_utf8.t @@ -21,7 +21,7 @@ BEGIN { # - SL BEGIN { $ENV{JSON_ANY_ORDER} = qw(XS); - $ENV{JSON_ANY_CONFIG} = "utf8=1"; + $ENV{JSON_ANY_CONFIG} = "utf8=0"; } plan tests => 8; use_ok('MooseX::Storage');