1use strict;
2use Test::More;
3BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }
4use JSON::PP;
5
6#SKIP_ALL_UNLESS_PP 2.90
7
8BEGIN { plan tests => 2 };
9
10my $json = JSON::PP->new;
11my $kb = 'a' x 1024;
12my $hash = { map { $_ => $kb } (1..40) };
13my $data = join ( '', $json->encode($hash), $json->encode($hash) );
14my $size = length($data);
15# note "Total size: [$size]";
16my $offset = 0;
17while ($size) {
18    # note "Bytes left [$size]";
19    my $incr = substr($data, $offset, 4096);
20    my $bytes = length($incr);
21    $size -= $bytes;
22    $offset += $bytes;
23    if ($bytes) {
24        $json->incr_parse($incr);
25    }
26    while( my $obj = $json->incr_parse ) {
27        ok "Got JSON object";
28    }
29}
30