1use Test::More;
2BEGIN {
3  # for cperl CORE
4  eval "require JSON::PP;";
5  if ($@) {
6    plan skip_all => "JSON::PP required for testing interop_pp";
7    exit 0;
8  } else {
9    plan tests => 3;
10  }
11  $ENV{PERL_JSON_BACKEND} = 0;
12}
13
14use JSON::PP (); # limitation: for interop with JSON load JSON::PP before Cpanel::JSON::XS
15use Cpanel::JSON::XS ();
16
17my $cjson = Cpanel::JSON::XS->new;
18my $boolstring = q({"is_true":true});
19my $js;
20{
21    local $ENV{PERL_JSON_BACKEND} = 'JSON::PP';
22    my $json = JSON::PP->new;
23    $js = $json->decode( $boolstring );
24    # bless { is_true => 1 }, "JSON::PP::Boolean"
25}
26
27is ($cjson->encode( $js ), $boolstring) or diag "\$JSON::VERSION=$JSON::VERSION";
28
29{
30    local $ENV{PERL_JSON_BACKEND} = 'Cpanel::JSON::XS';
31    my $json = JSON::PP->new;
32    $js = $json->decode( $boolstring );
33    # bless { is_true => 1}, "Types::Serialiser"
34}
35
36is($cjson->encode( $js ), $boolstring)
37  or diag "\$JSON::PP::VERSION=$JSON::PP::VERSION";
38
39$js = $cjson->decode( $boolstring );
40is ($cjson->encode( $js ), $boolstring) or diag(ref $js->{is_true});
41
42