Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/JSON/PP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ sub allow_bigint {
$self->_down_indent() if ($self->{PROPS}[P_INDENT]);

return '[]' unless @res;
return '[' . $pre . join( ",$pre", @res ) . $post . ']';
my $space = $pre eq '' && $self->{PROPS}[P_SPACE_AFTER] ? ' ' : '';
return '[' . $pre . join( ",$space$pre", @res ) . $post . ']';
}

sub _looks_like_number {
Expand Down
15 changes: 15 additions & 0 deletions t/gh_89_space_after_comma.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use strict;
use warnings;
use Test::More;

BEGIN { $ENV{PERL_JSON_BACKEND} = 0; }

my @candidates = qw(JSON::PP JSON::XS Cpanel::JSON::XS);

for my $json_module (@candidates) {
eval "require $json_module; 1" or next;
my $got = $json_module->new->utf8->space_after(1)->encode({x=>[1,2]});
is $got => qq!{"x": [1, 2]}!, "$json_module has a space after 1";
}

done_testing;
Loading