1 package Config::Any::JSON;
8 Config::Any::JSON - Load JSON config files
12 Loads JSON files. Example:
28 return an array of valid extensions (C<json>, C<jsn>).
33 return qw( json jsn );
38 Attempts to load C<$file> as a JSON file.
46 open( my $fh, $file ) or die $!;
47 my $content = do { local $/; <$fh> };
50 eval { require JSON::Syck; };
53 eval { JSON->VERSION( 2 ); };
54 return $@ ? JSON::jsonToObj( $content ) : JSON::from_json( $content );
57 return JSON::Syck::Load( $content );
61 =head2 is_supported( )
63 Returns true if either L<JSON::Syck> or L<JSON> is available.
68 eval { require JSON::Syck; };
70 eval { require JSON; };
76 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
78 =head1 COPYRIGHT AND LICENSE
80 Copyright 2007 by Brian Cassidy
82 This library is free software; you can redistribute it and/or modify
83 it under the same terms as Perl itself.
91 =item * L<Config::Any>