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(@_); } 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; +}