An efficient JSON parser written in Python.
Install it via pip:
pip install json-parser
import json_parser
data = json_parser.parse('{"value": 42}')
print(data['value']) # 42
Running it on this 25MB JSON file gave the following results:
>>> with open('large-file.json') as f:
... t = time.time()
... x = json.load(f)
... t = time.time() - t
... print(t, 'seconds')
...
0.6405608654022217 seconds
>>> with open('large-file.json') as f:
... t = time.time()
... y = json_parser.parse(f.read())
... t = time.time() - t
... print(t, 'seconds')
...
22.286625385284424 seconds
>>> x == y
True
So, it's about 34x slower than the builtin json
.
Which, is par for the course when it comes to pure python.
Clone the app and run the following:
pip install -e '.[dev]'
pytest