xref: /openbsd-src/gnu/usr.bin/perl/cpan/JSON-PP/t/107_allow_singlequote.t (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
1
2use Test::More;
3use strict;
4use warnings;
5BEGIN { plan tests => 4 };
6BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }
7use JSON::PP;
8#########################
9
10my $json = JSON::PP->new->allow_nonref;
11
12eval q| $json->decode("{'foo':'bar'}") |;
13
14ok($@); # in XS and PP, the error message differs.
15
16$json->allow_singlequote;
17
18is($json->decode(q|{'foo':"bar"}|)->{foo}, 'bar');
19is($json->decode(q|{'foo':'bar'}|)->{foo}, 'bar');
20is($json->allow_barekey->decode(q|{foo:'bar'}|)->{foo}, 'bar');
21
22