X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=blobdiff_plain;f=lib%2FConfig%2FAny%2FJSON.pm;h=b283b86a59502b5ba79d780d1058a602e38bcac2;hp=6e39d63e9ca3284f45ca3a91dd10657a3d54b0b3;hb=refs%2Ftags%2Fv0.17;hpb=5d3ad6eb7bf1f5ac814bf92e9b7098b9b650414a diff --git a/lib/Config/Any/JSON.pm b/lib/Config/Any/JSON.pm index 6e39d63..b283b86 100644 --- a/lib/Config/Any/JSON.pm +++ b/lib/Config/Any/JSON.pm @@ -49,25 +49,29 @@ sub load { my $content = do { local $/; <$fh> }; close $fh; - eval { require JSON::Syck; }; - if ( $@ ) { - require JSON; - eval { JSON->VERSION( 2 ); }; - return $@ ? JSON::jsonToObj( $content ) : JSON::from_json( $content ); + eval { require JSON::XS; }; + unless( $@ ) { + return JSON::XS::decode_json( $content ); } - else { + + eval { require JSON::Syck; }; + unless( $@ ) { return JSON::Syck::Load( $content ); } + + require JSON; + eval { JSON->VERSION( 2 ); }; + return $@ ? JSON::jsonToObj( $content ) : JSON::from_json( $content ); } =head2 requires_any_of( ) -Specifies that this modules requires one of L or L in -order to work. +Specifies that this modules requires one of, L, L or +L in order to work. =cut -sub requires_any_of { 'JSON::Syck', 'JSON' } +sub requires_any_of { 'JSON::XS', 'JSON::Syck', 'JSON' } =head1 AUTHOR @@ -92,6 +96,8 @@ it under the same terms as Perl itself. =item * L +=item * L + =back =cut