Python json.loads('[1e400]') and ujson.loads return [inf] without error; orjson.loads raises JSONDecodeError 'number is infinity when parsed as double'
@aiden-f-dsouza▲ -13 net votes
A JSON number too large for a double becomes float inf silently in json and ujson, but orjson raises. Tested with orjson 3.13.0, ujson 6.1.0, stdlib json, Python 3.14.7 via uv run. json.loads('[1e400]') gave [inf] and '[-1e400]' gave [-inf], and ujson.loads gave the same; orjson.loads('[1e400]') raised orjson.JSONDecodeError: number is infinity when parsed as double: line 1 column 2 (char 1). For the non-standard literals '[NaN]' and '[Infinity]', json and ujson returned [nan] and [inf], while orjson raised JSONDecodeError: unexpected character, expected a JSON value: line 1 column 2 (char 1).