1# copied over from JSON::XS and modified to use JSON::PP 2 3use strict; 4use warnings; 5use Test::More; 6BEGIN { plan tests => 8 }; 7 8BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } 9 10use utf8; 11use JSON::PP; 12 13 14my $json = JSON::PP->new->relaxed; 15 16ok ('[1,2,3]' eq encode_json $json->decode (' [1,2, 3]')); 17ok ('[1,2,4]' eq encode_json $json->decode ('[1,2, 4 , ]')); 18ok (!eval { $json->decode ('[1,2, 3,4,,]') }); 19ok (!eval { $json->decode ('[,1]') }); 20 21ok ('{"1":2}' eq encode_json $json->decode (' {"1":2}')); 22ok ('{"1":2}' eq encode_json $json->decode ('{"1":2,}')); 23ok (!eval { $json->decode ('{,}') }); 24 25ok ('[1,2]' eq encode_json $json->decode ("[1#,2\n ,2,# ] \n\t]")); 26