Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

JSON 2.x compatiblity

  • Loading branch information...
commit 0b97c3755ad3275619c5c6ca6b484497b6e6a35c 1 parent b883887
@miyagawa miyagawa authored
Showing with 12 additions and 7 deletions.
  1. +1 −2  Makefile.PL
  2. +11 −5 t/01_server.t
View
3  Makefile.PL
@@ -4,9 +4,8 @@ name 'Catalyst-View-JSON';
all_from 'lib/Catalyst/View/JSON.pm';
build_requires 'Test::More';
-build_requires $_ for qw( JSON JSON::Parser JSON::Converter );
-requires 'JSON::Any', 1.11;
+requires 'JSON::Any', 1.15;
requires 'Catalyst', 5.60;
auto_include;
View
16 t/01_server.t
@@ -5,9 +5,15 @@ use FindBin;
use lib "$FindBin::Bin/lib";
use Encode;
-use Test::More tests => 38;
+use Test::More;
use Catalyst::Test 'TestApp';
-use JSON ();
+
+eval "use JSON 2.04";
+if ($@) {
+ plan skip_all => "JSON 2.04 is needed for testing";
+}
+
+plan tests => 38;
BEGIN {
no warnings 'redefine';
@@ -34,7 +40,7 @@ my $entrypoint = "http://localhost/foo";
is( $response->code, 200, 'Response Code' );
is_deeply( [ $response->content_type ], [ 'application/json', 'charset=utf-8' ] );
- my $data = JSON::jsonToObj($response->content);
+ my $data = JSON::from_json($response->content);
is $data->{json_foo}, "bar";
is_deeply $data->{json_baz}, [ 1, 2, 3 ];
ok ! $data->{foo}, "doesn't return stash that doesn't match json_";
@@ -48,7 +54,7 @@ my $entrypoint = "http://localhost/foo";
is( $response->code, 200, 'Response Code' );
is_deeply( [ $response->content_type ], [ 'application/json', 'charset=utf-8' ] );
- my $data = JSON::jsonToObj($response->content);
+ my $data = JSON::from_json($response->content);
is_deeply( $data, [1, 2, 3] );
}
@@ -63,7 +69,7 @@ my $entrypoint = "http://localhost/foo";
my $body = $response->content;
ok $body =~ s/^foobar\((.*?)\);$/$1/sg, "wrapped in a callback";
- my $data = JSON::jsonToObj($body);
+ my $data = JSON::from_json($body);
is $data->{json_foo}, "bar";
is_deeply $data->{json_baz}, [ 1, 2, 3 ];
ok ! $data->{foo}, "doesn't return stash that doesn't match json_";
Please sign in to comment.
Something went wrong with that request. Please try again.