Numbers with extra prefix 0 should not be accepted as valid input
What did you do?
ujson.loads("0012")
What did you expect to happen?
exception raised, ValueError for example
What actually happened?
function returns 12
What versions are you using?
- OS: Debian 10
- Python: 3.7.3
- UltraJSON: 5.7.0
Please include code that reproduces the issue.
The best reproductions are self-contained scripts with minimal dependencies.
try:
ujson.loads("0012")
print("not ok")
except ValueError:
print("ok")
The JSON spec explicitly allows parsers to accept input that isn't part of the spec but whose intention is clear and non ambiguous.
Beyond purism, why does this actually matter?
The JSON spec explicitly allows parsers to accept input that isn't part of the spec but whose intention is clear and non ambiguous.
Beyond purism, why does this actually matter?
I was porting code from python standard json to ujson for better performance, and the code relies on loads("0012") to fail.
You're probably better off going with orjson then. They take the opposite stance to us on accepting non standard inputs.