From 23136272f8d39131c9b596f5dbc26880be5e208f Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Sun, 4 Jan 2026 21:59:45 +0900 Subject: [PATCH 1/2] Add the same prototype as JSON::XS to decode_json --- 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 660ae7b..eca2897 100644 --- a/lib/JSON/PP.pm +++ b/lib/JSON/PP.pm @@ -112,7 +112,7 @@ sub encode_json ($) { # encode } -sub decode_json { # decode +sub decode_json ($) { # decode ($JSON ||= __PACKAGE__->new->utf8)->decode(@_); } From bc8732e1dd32ba287c8767d841ccd8e78b716d2b Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Sun, 4 Jan 2026 21:59:58 +0900 Subject: [PATCH 2/2] Add a test --- t/gh_54_context_sensitive_read_file.t | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 t/gh_54_context_sensitive_read_file.t diff --git a/t/gh_54_context_sensitive_read_file.t b/t/gh_54_context_sensitive_read_file.t new file mode 100644 index 0000000..2cbd3da --- /dev/null +++ b/t/gh_54_context_sensitive_read_file.t @@ -0,0 +1,21 @@ +use strict; +use warnings; +use Test::More; + +BEGIN { plan tests => 1 }; + +BEGIN { $ENV{PERL_JSON_BACKEND} = 0; } + +use JSON::PP; + +my $ds = eval { JSON::PP::decode_json read_file() }; +ok !$@, "No error" or note $@; + +sub read_file { + my $json = <<"JSON"; +{ +"camel": "Amelia" +} +JSON + wantarray ? split(/\R/, $json) : $json; +}