Summary
PerlOnJava's JSON decoder does not preserve the numeric scalar nature of JSON numbers. This breaks consumers that distinguish numbers from strings using Perl scalar flags, including JSON::Pointer.
Affected software
- CPAN distribution:
JSON-Pointer 0.07
- Dependency:
Class::Accessor::Lite 0.08
- CPAN regression run:
20260904-185312-10032
- Failing test:
t/009_test.t
The complete upstream suite passes under system Perl: 11 test files and 51 tests. PerlOnJava reproduces the failure on both the JVM and interpreter backends.
Minimal reproducer
use JSON;
use JSON::Pointer;
my $document = decode_json('{"a":1}');
print JSON::Pointer->test($document, '/a', 1), "\n";
Expected output:
PerlOnJava output:
Root cause
JSON::Pointer::test uses B::svref_2object flags to distinguish numeric and string values:
my $flags = B::svref_2object(\$value)->FLAGS;
return (($flags & (B::SVp_IOK | B::SVp_NOK)) && !($flags & B::SVp_POK));
Under standard Perl, decode_json gives the decoded number numeric flags. Under PerlOnJava, the decoded number is represented as a string-only scalar (POK without IOK/NOK). JSON::Pointer therefore treats the document value 1 as a string while the expected literal 1 is numeric, and returns false.
Impact
This affects JSON consumers that rely on Perl's numeric/string scalar distinction or inspect B flags. In JSON::Pointer, traversal and pointer escaping work correctly, but numeric equality checks for values decoded from JSON fail. The regression caused 9 RFC example cases in t/009_test.t to fail.
Expected fix
Ensure JSON numeric tokens produce numeric PerlOnJava scalars with behavior equivalent to system Perl, including numeric coercion/flag semantics, or provide a runtime-compatible numeric-type mechanism for code using B flags. Preserve the distinction between JSON numbers and JSON strings.
Add permanent regression coverage for decoded numeric values versus numeric and string expected values, and validate both execution backends.
Summary
PerlOnJava's JSON decoder does not preserve the numeric scalar nature of JSON numbers. This breaks consumers that distinguish numbers from strings using Perl scalar flags, including
JSON::Pointer.Affected software
JSON-Pointer0.07Class::Accessor::Lite0.0820260904-185312-10032t/009_test.tThe complete upstream suite passes under system Perl: 11 test files and 51 tests. PerlOnJava reproduces the failure on both the JVM and interpreter backends.
Minimal reproducer
Expected output:
PerlOnJava output:
Root cause
JSON::Pointer::testusesB::svref_2objectflags to distinguish numeric and string values:Under standard Perl,
decode_jsongives the decoded number numeric flags. Under PerlOnJava, the decoded number is represented as a string-only scalar (POKwithoutIOK/NOK).JSON::Pointertherefore treats the document value1as a string while the expected literal1is numeric, and returns false.Impact
This affects JSON consumers that rely on Perl's numeric/string scalar distinction or inspect
Bflags. InJSON::Pointer, traversal and pointer escaping work correctly, but numeric equality checks for values decoded from JSON fail. The regression caused 9 RFC example cases int/009_test.tto fail.Expected fix
Ensure JSON numeric tokens produce numeric PerlOnJava scalars with behavior equivalent to system Perl, including numeric coercion/flag semantics, or provide a runtime-compatible numeric-type mechanism for code using
Bflags. Preserve the distinction between JSON numbers and JSON strings.Add permanent regression coverage for decoded numeric values versus numeric and string expected values, and validate both execution backends.