=head1 NAME
JSON::Builder - to build large JSON with temp files when memory limit, and compress optionaly.
=head1 SYNOPSIS
use JSON::Builder;
my $json = JSON::XS->new()->utf8(1)->ascii(1);
my
empfile();
unlink $filename;
my $builder = JSON::Builder->new(json => $json, fh => $fh);
or
my $builder = JSON::Builder::Compress->new(json => $json, fh => $fh); # Compress, Base64
my $fv =
ek(0,0);
print <$fh>;
=head1 MOTIVATION
Task: to create JSON while having the memory limitations.
If you have only one large value in JSON, or, large values are created one by one, you can use the
ings;
use JSON::XS;
use File::Temp qw(tempfile);
use Compress::Zlib;
use MIME::Base64;
use URI::Escape;
use Test::More tests => 5;
BEGIN { use_ok( 'JSON::Builder' ) }
my $json = JSON::XS->new()
INK => 1);
my $builder = JSON::Builder->new(
json => $json,
fh => $fh,
read_in => 1000*57
);
build($fh, $builder);
my $r = read_fh($fh);
is_deeply($json->decode($r), $j, "Simple"
file(UNLINK => 1);
my ($fh_plain) = tempfile(UNLINK => 1);
my $builder = JSON::Builder::Compress->new(
json => $json,
fh => $fh,
read_in => 1000*57,
fh_plain => $fh_plain,
);