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