1use Test::More; 2use strict; 3use warnings; 4BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } 5BEGIN { $ENV{PERL_JSON_PP_USE_B} = 0 } 6use JSON::PP; 7 8#SKIP_ALL_UNLESS_PP 2.90 9#SKIP_ALL_IF_XS 10 11BEGIN { plan tests => 3 } 12 13# TODO ("inf"/"nan" representations are not portable) 14# is encode_json([9**9**9]), '["inf"]'; 15# is encode_json([-sin(9**9**9)]), '["nan"]'; 16 17my $num = 3; 18my $str = "$num"; 19is encode_json({test => [$num, $str]}), '{"test":[3,"3"]}'; 20$num = 3.21; 21$str = "$num"; 22is encode_json({test => [$num, $str]}), '{"test":[3.21,"3.21"]}'; 23$str = '0 but true'; 24$num = 1 + $str; 25is encode_json({test => [$num, $str]}), '{"test":[1,"0 but true"]}'; 26