1 2use strict; 3use Test::More; 4BEGIN { plan tests => 2 }; 5 6BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } 7 8use JSON::PP; 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 $json = JSON::PP->new; 29 30 my $js = $json->encode(\%columns); 31 is( $js, q/{"id":"int","1":"a","2":"b","3":"c","4":"d","5":"e"}/ ); 32 33 $js = $json->pretty->encode(\%columns); 34 is( $js, <<'STR' ); 35{ 36 "id" : "int", 37 "1" : "a", 38 "2" : "b", 39 "3" : "c", 40 "4" : "d", 41 "5" : "e" 42} 43STR 44 45} 46 47