Revision history for Config-Any
-0.17 XXX
+0.17 Thu 05 Feb 2009
- ensure require() happens against plugin specified in force_plugins.
+ - add JSON::XS to the top of the JSON loaders list
0.16 Mon 17 Nov 2008
- fix up branches test which did not handle the errors thrown by
my $content = do { local $/; <$fh> };
close $fh;
- eval { require JSON::Syck; };
- if ( $@ ) {
- require JSON;
- eval { JSON->VERSION( 2 ); };
- return $@ ? JSON::jsonToObj( $content ) : JSON::from_json( $content );
+ eval { require JSON::XS; };
+ unless( $@ ) {
+ return JSON::XS::decode_json( $content );
}
- else {
+
+ eval { require JSON::Syck; };
+ unless( $@ ) {
return JSON::Syck::Load( $content );
}
+
+ require JSON;
+ eval { JSON->VERSION( 2 ); };
+ return $@ ? JSON::jsonToObj( $content ) : JSON::from_json( $content );
}
=head2 requires_any_of( )
-Specifies that this modules requires one of L<JSON::Syck> or L<JSON> in
-order to work.
+Specifies that this modules requires one of, L<JSON::XS>, L<JSON::Syck> or
+L<JSON> in order to work.
=cut
-sub requires_any_of { 'JSON::Syck', 'JSON' }
+sub requires_any_of { 'JSON::XS', 'JSON::Syck', 'JSON' }
=head1 AUTHOR
=item * L<JSON::Syck>
+=item * L<JSON::XS>
+
=back
=cut
my $file = shift;
eval { require YAML::Syck; YAML::Syck->VERSION( '0.70' ) };
- if ( $@ ) {
- require YAML;
- return YAML::LoadFile( $file );
- }
- else {
+ unless ( $@ ) {
open( my $fh, $file ) or die $!;
my $content = do { local $/; <$fh> };
close $fh;
return YAML::Syck::Load( $content );
}
+
+ require YAML;
+ return YAML::LoadFile( $file );
}
=head2 requires_any_of( )