1 package Catalyst::Plugin::ConfigLoader::JSON;
\r
10 Catalyst::Plugin::ConfigLoader::JSON - Load JSON config files
\r
14 Loads JSON files. Example:
\r
18 "Controller::Config": {
\r
25 =head2 load( $file )
\r
27 Attempts to load C<$file> as a JSON file.
\r
33 my $confpath = shift;
\r
36 if( $confpath =~ /\.(.{3,4})$/ ) {
\r
37 return unless $1 =~ /^jso?n$/;
\r
41 @files = map { "$confpath.$_" } qw( json jsn );
\r
44 for my $file ( @files ) {
\r
45 next unless -f $file;
\r
47 my $content = read_file( $file );
\r
49 eval { require JSON::Syck; };
\r
53 return jsonToObj( $content );
\r
56 return JSON::Syck::Load( $content );
\r
65 =item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>
\r
69 =head1 COPYRIGHT AND LICENSE
\r
71 Copyright 2006 by Brian Cassidy
\r
73 This library is free software; you can redistribute it and/or modify
\r
74 it under the same terms as Perl itself.
\r