diff --git a/.github/workflows/testsuite.yml b/.github/workflows/testsuite.yml index 758033a..208602d 100644 --- a/.github/workflows/testsuite.yml +++ b/.github/workflows/testsuite.yml @@ -68,6 +68,8 @@ jobs: - uses: actions/checkout@v1 - name: perl -V run: perl -V + - name: Install dependencies + run: curl -sL https://git.io/cpm | perl - install -g --with-recommends --with-test --with-configure --show-build-log-on-failure - name: Makefile.PL run: perl -I$(pwd) Makefile.PL - name: make test diff --git a/Makefile.PL b/Makefile.PL index c329829..f68c97a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -16,7 +16,7 @@ WriteMakefile( 'NAME' => 'JSON::PP', 'VERSION_FROM' => 'lib/JSON/PP.pm', # finds $VERSION 'PREREQ_PM' => { - 'Test::More' => 0, + 'Test::More' => 0.88, 'Scalar::Util' => '1.08' }, 'EXE_FILES' => [ 'bin/json_pp' ], diff --git a/lib/JSON/PP.pm b/lib/JSON/PP.pm index eca2897..c910561 100644 --- a/lib/JSON/PP.pm +++ b/lib/JSON/PP.pm @@ -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 { diff --git a/t/gh_89_space_after_comma.t b/t/gh_89_space_after_comma.t new file mode 100644 index 0000000..fd3a48a --- /dev/null +++ b/t/gh_89_space_after_comma.t @@ -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;