e tests that we support
if (eval {require JSON}) {
my $_file = $tmpnam. '.json';
$TESTS{json} = sub {
$cob->write_ref($file, $str);
};
$files{json} = $_file;
}
if (eval {require Storable}
\&read_handler_yaml,
'conf' => \&read_handler_yaml,
'json' => \&read_handler_json,
'val_json' => \&read_handler_json,
'ini' => \&read_handler_ini,
'pl' => \&read
write_handler_yaml,
'ini' => \&write_handler_ini,
'json' => \&write_handler_json,
'val_json' => \&write_handler_json,
'pl' => \&write_handler_pl,
'sto' => \&wri
ad_handler_json {
my $file = shift;
local *IN;
open (IN, $file) || die "Couldn't open $file: $!";
CORE::read(IN, my $text, -s $file);
close IN;
require JSON;
my $decode = JSON->can('deco
package CGI::Ex::JSONDump;
=head1 NAME
CGI::Ex::JSONDump - Comprehensive data to JSON dump.
=head1 VERSION
version 2.55
=cut
###----------------------------------------------------------------##
use Exporter qw(import);
our $VERSION = '2.55'; # VERSION
our @EXPORT = qw(JSONDump);
our @EXPORT_OK = @EXPORT;
sub JSONDump {
my ($data, $args) = @_;
return __PACKAGE__->new($args)->dump($
or really odd chars
$str =~ s/([\x00-\x07\x0b\x0e-\x1f])/'\\u00' . unpack('H2',$1)/eg; # from JSON::Converter
utf8::decode($str) if $self->{'utf8'} && &utf8::decode;
### escape <html> and
#!/usr/bin/perl -w
# As of JSON switch to 2.0 and new JSON interface
# Benchmark: running cejd, json, zejd for at least 2 CPU seconds...
# cejd: 3 wallclock secs ( 2.17 usr + 0.00 sys = 2.17
json: 3 wallclock secs ( 2.24 usr + 0.00 sys = 2.24 CPU) @ 8723.21/s (n=19540)
# zejd: 3 wallclock secs ( 2.16 usr + 0.00 sys = 2.16 CPU) @ 7111.11/s (n=15360)
# Rate cejd zejd json
%
# json 8723/s 23% 23% --
#
# Benchmark: running cejd, json for at least 2 CPU seconds...
# cejd: 3 wallclock secs ( 2.08 usr + 0.00 sys = 2.08 CPU) @ 5800.48/s (n=12065)
# json:
re CGI::Ex::JSONDump;
my $json = CGI::Ex::JSONDump->new({pretty => 1})->dump($val_hash);
return qq{<script src="$js_uri_path_validate"></script>
<script>
document.validation = $json;
if (docum
using the capabilities of CGI::Ex::Validate and
CGI::Ex::JSONDump. This will call the hook hash_validation which will
then be encoded into json and placed in a javascript string. It will
also call t
{require JSON}) {
my $_file = File::Temp->new(SUFFIX => '.json');
my $str = JSON::objToJson($conf, {pretty => 1, indent => 2});
open(my $fh, ">$_file");
print $fh $str;
$TESTS{json} = sub {
);
};
$TESTS{json2} = sub {
open(my $fh, "<$_file") || die "Couldn't open file: $!";
read($fh, my $str, -s $_file);
my $hash = JSON::jsonToObj($str);
};
$files{json} = $_file;
}