The JSON scanner currently accepts numbers with leading zeros, such as 01 and 007.
These are not valid JSON numbers. According to the JSON number grammar, an integer component must be either exactly 0 or start with a non-zero digit followed by additional digits.
json.loads() correctly rejects these documents, but bytejson currently indexes them successfully and may return the parsed value during per-leaf access.
Reproduction
import bytejson
open("./tmp/leadzero.json", "w").write('{"n": 007}')
db = bytejson.open("./tmp/leadzero.json")
print(db["n"])
Observed:
The document is therefore accepted and interpreted as valid JSON.
The JSON scanner currently accepts numbers with leading zeros, such as
01and007.These are not valid JSON numbers. According to the JSON number grammar, an integer component must be either exactly
0or start with a non-zero digit followed by additional digits.json.loads()correctly rejects these documents, butbytejsoncurrently indexes them successfully and may return the parsed value during per-leaf access.Reproduction
Observed:
The document is therefore accepted and interpreted as valid JSON.