From: Graham Knop Date: Thu, 12 Apr 2018 13:50:47 +0000 (+0200) Subject: just use JSON::MaybeXS, not JSON.pm X-Git-Tag: v5.90118~24 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=1c9c3b77c6192f4cdb713b60ee9472b112a43d5a just use JSON::MaybeXS, not JSON.pm --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 0ea132b..57d4928 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -4014,14 +4014,14 @@ only two default data handlers, for 'application/json' and an alternative to L or via L IF you've installed it. The 'application/json' data handler is used to parse incoming JSON into a Perl -data structure. It used either L or L, depending on which -is installed. This allows you to fail back to L, which is a Pure Perl -JSON decoder, and has the smallest dependency impact. +data structure. It uses L. This allows you to fail back to +L, which is a Pure Perl JSON decoder, and has the smallest dependency +impact. Because we don't wish to add more dependencies to L, if you wish to -use this new feature we recommend installing L or L in -order to get the best performance. You should add either to your dependency -list (Makefile.PL, dist.ini, cpanfile, etc.) +use this new feature we recommend installing L in order to get +the best performance. You should add either to your dependency list +(Makefile.PL, dist.ini, cpanfile, etc.) =cut @@ -4056,12 +4056,12 @@ sub default_data_handlers { }, 'application/json' => sub { my ($fh, $req) = @_; - my $parser = Class::Load::load_first_existing_class('JSON::MaybeXS', 'JSON'); + require JSON::MaybeXS; my $slurped; return eval { local $/; $slurped = $fh->getline; - $parser->can("decode_json")->($slurped); # decode_json does utf8 decoding for us + JSON::MaybeXS::decode_json($slurped); # decode_json does utf8 decoding for us } || Catalyst::Exception->throw(sprintf "Error Parsing POST '%s', Error: %s", (defined($slurped) ? $slurped : 'undef') ,$@); }, }; @@ -4587,7 +4587,7 @@ that parses that content type into something Perl can readily access. package MyApp::Web; use Catalyst; - use JSON::Maybe; + use JSON::MaybeXS; __PACKAGE__->config( data_handlers => { @@ -4599,7 +4599,7 @@ that parses that content type into something Perl can readily access. __PACKAGE__->setup; By default L comes with a generic JSON data handler similar to the -example given above, which uses L to provide either L +example given above, which uses L to provide either L (a pure Perl, dependency free JSON parser) or L if you have it installed (if you want the faster XS parser, add it to you project Makefile.PL or dist.ini, cpanfile, etc.)