==============================================
# Load Settings from outer file / must be a valid json file
#============================================================================
sub loadSett
ake::Utils::get_file($file);
}; if ($@){
die "can't open file $file";
}
##json to perl
return Cake::Utils->serialize($conf)->to_perl;
}
#==============================
lf->body(Dumper $data);
}
sub json {
my $self = shift;
my $data = shift;
if (ref $data eq 'HASH'){
$data = $self->serialize($data)->to_json;
}
$self->content_type
"jpg" => "image/jpeg",
"js" => "application/javascript",
"json" => "application/json",
"log" => "text/plain",
"m3u" => "audio/x-mpegurl",
"m4
ash;
}
1;
__END__
=head1 NAME
Cake::Plugin::I18N
=head1 SYNOPSIS
##in your settings.json
{
"plugins" : [
"I18N" : {
"path" : "/full/path/to/your/l
shift},$class);
}
sub true {'true' }
sub false { undef }
sub null { 'null' }
##from json to perl
sub to_perl {
my $self = shift;
#remove comments
$self->{data} =~ s/\n+\s
ata";
croak "invalid json" if $@;
#return bless($str,'Cake::Utils::Serializer::Base');
return $str;
return _stringify($data);
}
sub to_json {
my $self = shift;
1)->Pair(' : ');
my $json = $dumper->Dump;
$json =~ s/(?:'((.*?)[^\\'])?')/$1 ? '"'.$1.'"' : '""'/ge;
$json =~ s/\\'/'/g;
$json =~ s/\\\\/\\/g;
$json =~ s/(\\x\{(.*?)\})/chr(h