properly document JSON modules used
[p5sagit/Config-Any.git] / lib / Config / Any / JSON.pm
index 785f396..17055f3 100644 (file)
@@ -50,7 +50,15 @@ sub load {
     my $content = do { local $/; <$fh> };
     close $fh;
 
-    if ( eval { require JSON::DWIW } ) {
+    if ( eval { require Cpanel::JSON::XS } ) {
+        my $decoder = Cpanel::JSON::XS->new->utf8->relaxed;
+        return $decoder->decode( $content );
+    }
+    elsif ( eval { require JSON::MaybeXS } ) {
+        my $decoder = JSON::MaybeXS::JSON()->new->utf8->relaxed;
+        return $decoder->decode( $content );
+    }
+    elsif ( eval { require JSON::DWIW } ) {
         my $decoder = JSON::DWIW->new;
         my ( $data, $error ) = $decoder->from_json( $content );
         die $error if $error;
@@ -79,32 +87,45 @@ sub load {
 
 =head2 requires_any_of( )
 
-Specifies that this modules requires one of,  L<JSON::DWIW>, L<JSON::XS>,
-L<JSON::Syck> or L<JSON> in order to work.
+Specifies that this modules requires one of, L<Cpanel::JSON::XS>,
+L<JSON::MaybeXS>, L<JSON::DWIW>, L<JSON::XS>, L<JSON::Syck>, L<JSON::PP> or
+L<JSON> in order to work.
 
 =cut
 
-sub requires_any_of { 'JSON::DWIW', 'JSON::XS', 'JSON::Syck', 'JSON::PP', 'JSON' }
+sub requires_any_of { qw(
+  Cpanel::JSON::XS
+  JSON::MaybeXS
+  JSON::DWIW
+  JSON::XS
+  JSON::Syck
+  JSON::PP
+  JSON
+) }
 
 =head1 AUTHOR
 
-Brian Cassidy E<lt>bricas@cpan.orgE<gt>
+Brian Cassidy <bricas@cpan.org>
 
 =head1 COPYRIGHT AND LICENSE
 
 Copyright 2006-2016 by Brian Cassidy
 
 This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself. 
+it under the same terms as Perl itself.
 
 =head1 SEE ALSO
 
-=over 4 
+=over 4
 
 =item * L<Catalyst>
 
 =item * L<Config::Any>
 
+=item * L<Cpanel::JSON::XS>
+
+=item * L<JSON::MaybeXS>
+
 =item * L<JSON::DWIW>
 
 =item * L<JSON::XS>