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=6c6eb6e20206215cf5476731139c4d3cbd25b37a;hp=5e4edf3ddbcf3c6679a19c9a0ae085e950961ade;hb=5a2e0210fe5c7da046be37b4240008f2b667be67;hpb=92a04e78451078b33f75e7c44d247b024c27b4f7 diff --git a/lib/Config/Any/JSON.pm b/lib/Config/Any/JSON.pm index 5e4edf3..6c6eb6e 100644 --- a/lib/Config/Any/JSON.pm +++ b/lib/Config/Any/JSON.pm @@ -50,24 +50,34 @@ sub load { eval { require JSON::Syck; }; if ( $@ ) { require JSON; - return JSON::jsonToObj( $content ); + eval { JSON->VERSION( 2 ); }; + return $@ ? JSON::jsonToObj( $content ) : JSON::from_json( $content ); } else { return JSON::Syck::Load( $content ); } } -=head1 AUTHOR +=head2 is_supported( ) -=over 4 +Returns true if either L or L is available. -=item * Brian Cassidy Ebricas@cpan.orgE +=cut -=back +sub is_supported { + eval { require JSON::Syck; }; + return 1 unless $@; + eval { require JSON; }; + return $@ ? 0 : 1; +} + +=head1 AUTHOR + +Brian Cassidy Ebricas@cpan.orgE =head1 COPYRIGHT AND LICENSE -Copyright 2006 by Brian Cassidy +Copyright 2007 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.