Skip to content

tusharsadhwani/json_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

json_parser

An efficient JSON parser written in Python.

Installation

Install it via pip:

pip install json-parser

Usage

import json_parser

data = json_parser.parse('{"value": 42}')
print(data['value']) # 42

Benchmarks

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.

Testing

Clone the app and run the following:

pip install -e '.[dev]'
pytest

About

An efficient(-ish) JSON parser written in Python.

Resources

License

Stars

Watchers

Forks

Languages