Closed mdorier closed 3 years ago
Note that in the following code, $a
is correctly encoded then decoded, while $b
failed to be decoded:
$a = {"x": -43};
$b = '{"x": -43}';
print "A ------";
print $a;
print json_encode($a);
print json_decode(json_encode($a));
print "B ------";
print $b;
print json_decode($b);
Output:
A ------
{"x":-43}
{"x":-43}
B ------
{"x": -43}
The Jx9 JSON decoder implementation does not handle negative number directly. This is obviously a wrong design choice or omission from the team.
To circumvent this, wrap your negative number in double quotes to be treated as a string, and make your conversion later from your jx9 script. You can rely on the built-in function is_numeric()
to check if a given string looks like a number.
This is really a Jx9 problem rather than unqlite but I'm reporting it here since there doesn't seem to be a repository for jx9, and both the forum link and the mailing list link are dead.
I'm using the version of Jx9 downloaded from here (version 1.7.2) on a Linux Debian. I'm executing this simple jx9 script, decoding a string into an object:
The execution indicates that
$b
is null, even though the object described by$a
is valid JSON.I tried using
JX9_VM_CONFIG_ERR_REPORT
withjx9_vm_config
to get more information about the problem but it doesn't print any error.