skip to navigation
skip to content

ijson 0.4.0

A Python wrapper to YAJL providing standard iterator interface to streaming JSON parsing

Downloads ↓

Latest Version: 0.8.0

Ijson is a Python wrapper to YAJL which is a streaming SAX-like JSON parser. Ijson provides a standard Python iterator interface for it.

Usage

Common usage:

from ijson import parse

f = urlopen('http://.../') # some huge JSON
parser = parse(f)
while True:
    prefix, event, value = parser.next()
    if prefix == 'earth.europe' and event == 'start_array':
        while prefix.startswith('earth.europe'):
            prefix, event, value = parser.next()
            if event == 'map_key':
                key = value
                prefix, event, value = parser.next()
                do_something_with(key, value)

Acknowledgements

Ijson was inspired by yajl-py wrapper by Hatem Nassrat. Though ijson borrows almost nothing from the actual yajl-py code it was used as an example of integration with yajl using ctypes.

 
File Type Py Version Uploaded on Size # downloads
ijson-0.4.0.tar.gz (md5) Source 2010-09-10 4KB 243