ijl / orjson

Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy
Apache License 2.0
6.29k stars 215 forks source link

Unable to parse deep JSON data #493

Closed afdw closed 5 months ago

afdw commented 5 months ago

I have fairly deep JSON data, and I would want to be able to parse it using orjson.

Currently it seem that the limit of depth when parsing JSON is hardcoded and can not be changed: https://github.com/ijl/orjson/blob/3c1f2a40d33861e31a8efc1647e3f9e6658c2c20/include/yyjson/yyjson.c#L333

Example code:

import orjson

n = 10000
s = "{\"a\": " * n + "0" + "}" * n
orjson.loads(s)

Output:

(venv) user@notebook:/tmp/tmp.L9DmvNqyEu$ python main.py 
Traceback (most recent call last):
  File "/tmp/tmp.L9DmvNqyEu/main.py", line 5, in <module>
    orjson.loads(s)
orjson.JSONDecodeError: array and object recursion depth exceeded: line 1 column 6146 (char 6145)

orjson version: 3.10.3.