package Data::Context::Loader::File::JSON;
# Created on: 2013-10-29 17:34:35
# Create by: Ivan Wills
# $Id$
# $Revision$, $HeadURL$, $Date$
# $Revision$, $Source$, $Date$
use Moose;
use version;
us
JSON::XS;
our $VERSION = version->new('0.3');
extends 'Data::Context::Loader::File';
has '+module' => (
default => 'JSON::XS',
);
sub loader {
my ($self, $file) = @_;
return JSON:
JSON - <One-line description of module's purpose>
=head1 VERSION
This documentation refers to Data::Context::Loader::File::JSON version 0.3
=head1 SYNOPSIS
use Data::Context::Loader::File::JSON
JSON::XS;
our $VERSION = version->new('0.3');
extends 'Data::Context::Loader::File';
has '+module' => (
default => 'JSON::XS',
);
sub loader {
my ($self, $file) = @_;
return JSON:
=head1 DESCRIPTION
=head1 SUBROUTINES/METHODS
=head2 C<loader ($file)>
Loads the file as loose JSON
=head1 DIAGNOSTICS
=head1 CONFIGURATION AND ENVIRONMENT
=head1 DEPENDENCIES
=head1 INCOMPATIB
ext::Manual
=head1 SYNOPSIS
# The config files (all produce the same data structures)
# JSON relaxed : data.dc.js
{
# shell/perl style comments ok
"PARENT": "other/path",
odule",
"METHOD" : "my_action",
},
},
}
# JSON strict : data.dc.json
{
"PARENT": "other/path",
"hash" : {
"key" : "value"
:Context> is it's simple handling of many configuration
files. It supports configuration files in JSON format (strict & relaxed
variants), YAML and XML (via XML::Simple). Basically the aim is to suppo
le version 0.3
=head1 SYNOPSIS
use Data::Context::Loader::File;
# Load a file of relaxed json type
my $file = Data::Context::Loader::File->new(
file => '/path/config.dc.js',
fault => sub {
return {
json => {
suffix => '.dc.json',
module => 'Data::Context::Loader::File::JSON',
},
js => {
is => 'rw',
isa => 'ArrayRefStr',
coerce => 1,
default => sub { [qw/js json yaml xml/] },
);
has default => (
is => 'rw',
isa => 'Str',
default => '_def
rom Data::Context::Actions
file_suffixes HASHREF
json => '.dc.json' : JSON::XS
js => '.dc.js' : JSON::XS->relaxed
yaml => '.dc.yml' : YAML or YAML::XS
h) is
my/config/file.dc.js
my/config/file.dc.json
my/config/file.dc.yml
my/config/file.dc.xml
my/config/_default.dc.js
my/config/_default.dc.json
my/config/_default.dc.yml
my/config/_default.
xes will be used for loading the
various config types. Default:
{
js => '.dc.js',
json => '.dc.json',
yaml => '.dc.yml',
xml => '.dc.xml',
}
=item file_suffix_order
Specify the ord