From: John Napiorkowski Date: Thu, 17 Oct 2013 00:08:49 +0000 (-0500) Subject: use more popular json parsers X-Git-Tag: 5.90050~1^2~39 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=3efd4eb3c8b9b735b4671fcf6f0bced1f6e81a85 use more popular json parsers --- diff --git a/Changes b/Changes index 88f0971..7dd89c5 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ # This file documents the revision history for Perl extension Catalyst. +5.90049_004 - TBA + - JSON Data handler looks for both JSON::MaybeXS and JSON, and uses + whichever is first (prefering to find JSON::MaybeXS). This should + improve compatibility as you likely already have one installed. + 5.90049_003 - 2013-09-20 - Documented the new body_data method added in the previous release - Merged from master many important bugfixes and forward compatiblity diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 04309c1..aa98926 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -3165,15 +3165,17 @@ you really don't need to invoke it. =head2 default_data_handlers -Default Data Handler that come bundled with L. Currently there is -only one default data handler, for 'application/json'. This uses L -which uses the dependency free L OR L if you have -installed it. If you don't mind the XS dependency, you should add the faster -L to you dependency list (in your Makefile.PL or dist.ini, or -cpanfile, etc.) +Default Data Handlers that come bundled with L. Currently there is +only one default data handler, for 'application/json'. This 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. -L is loaded the first time you ask for it (so if you never ask -for it, its never used). +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.) =cut @@ -3200,9 +3202,9 @@ sub default_data_handlers { my ($class) = @_; return +{ 'application/json' => sub { - local $/; - Class::Load::load_class("JSON::MaybeXS"); - JSON::MaybeXS::decode_json $_->getline }, + Class::Load::load_first_existing_class('JSON::MaybeXS', 'JSON') + ->can('decode_json')->(do { local $/; $_->getline }); + }, }; }