From 46afe3e6f2df9caf7e143d7e9b10b40d14eaf984 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Sun, 4 Jan 2026 22:26:27 +0900 Subject: [PATCH 1/5] Add space(s) after commas in an array as well --- lib/JSON/PP.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/JSON/PP.pm b/lib/JSON/PP.pm index eca2897..836330c 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 = $self->{PROPS}[P_SPACE_AFTER] ? ' ' : ''; + return '[' . $pre . join( ",$space$pre", @res ) . $post . ']'; } sub _looks_like_number { From 23f714a03fd235239b99f3838c6a0f8d30c91633 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Sun, 4 Jan 2026 22:26:35 +0900 Subject: [PATCH 2/5] Add a test --- t/gh_89_space_after_comma.t | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 t/gh_89_space_after_comma.t 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; From f26a18868f8ce638343c017a2b38260c365b2348 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Sun, 4 Jan 2026 22:39:30 +0900 Subject: [PATCH 3/5] Only add spaces if nothing else will be added --- lib/JSON/PP.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/JSON/PP.pm b/lib/JSON/PP.pm index 836330c..c910561 100644 --- a/lib/JSON/PP.pm +++ b/lib/JSON/PP.pm @@ -450,7 +450,7 @@ sub allow_bigint { $self->_down_indent() if ($self->{PROPS}[P_INDENT]); return '[]' unless @res; - my $space = $self->{PROPS}[P_SPACE_AFTER] ? ' ' : ''; + my $space = $pre eq '' && $self->{PROPS}[P_SPACE_AFTER] ? ' ' : ''; return '[' . $pre . join( ",$space$pre", @res ) . $post . ']'; } From 97ac40b8c3177c415caa95d46397c307a32f06c3 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Fri, 20 Mar 2026 16:12:00 +0900 Subject: [PATCH 4/5] Require better Test::More for CI --- Makefile.PL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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' ], From 2383b8a59b714bf7df91c127a380c077b762e491 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Fri, 20 Mar 2026 16:16:54 +0900 Subject: [PATCH 5/5] Install dependencies if needed --- .github/workflows/testsuite.yml | 2 ++ 1 file changed, 2 insertions(+) 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