1 2use strict; 3use Test::More; 4BEGIN { plan tests => 2 }; 5 6BEGIN { $ENV{PERL_JSON_BACKEND} = "JSON::backportPP"; } 7 8use JSON; 9 10# from https://rt.cpan.org/Ticket/Display.html?id=25162 11 12SKIP: { 13 eval {require Tie::IxHash}; 14 skip "Can't load Tie::IxHash.", 2 if ($@); 15 16 my %columns; 17 tie %columns, 'Tie::IxHash'; 18 19 %columns = ( 20 id => 'int', 21 1 => 'a', 22 2 => 'b', 23 3 => 'c', 24 4 => 'd', 25 5 => 'e', 26 ); 27 28 my $js = to_json(\%columns); 29 is( $js, q/{"id":"int","1":"a","2":"b","3":"c","4":"d","5":"e"}/ ); 30 31 $js = to_json(\%columns, {pretty => 1}); 32 is( $js, <<'STR' ); 33{ 34 "id" : "int", 35 "1" : "a", 36 "2" : "b", 37 "3" : "c", 38 "4" : "d", 39 "5" : "e" 40} 41STR 42 43} 44 45