1 package Config::Any::JSON;
6 use base 'Config::Any::Base';
10 Config::Any::JSON - Load JSON config files
14 Loads JSON files. Example:
30 return an array of valid extensions (C<json>, C<jsn>).
35 return qw( json jsn );
40 Attempts to load C<$file> as a JSON file.
48 open( my $fh, $file ) or die $!;
49 my $content = do { local $/; <$fh> };
52 eval { require JSON::Syck; };
55 eval { JSON->VERSION( 2 ); };
56 return $@ ? JSON::jsonToObj( $content ) : JSON::from_json( $content );
59 return JSON::Syck::Load( $content );
63 =head2 requires_any_of( )
65 Specifies that this modules requires one of L<JSON::Syck> or L<JSON> in
70 sub requires_any_of { 'JSON::Syck', 'JSON' }
74 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
76 =head1 COPYRIGHT AND LICENSE
78 Copyright 2007 by Brian Cassidy
80 This library is free software; you can redistribute it and/or modify
81 it under the same terms as Perl itself.
89 =item * L<Config::Any>