Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Iterative JSON parser with Pythonic interface

tag: 0.3.0

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 ijson
Octocat-spinner-32 LICENSE.txt Initial commit August 26, 2010
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.txt
Octocat-spinner-32 setup.py
Octocat-spinner-32 tests.py
README.txt
=====
ijson
=====

Ijson is a Python wrapper to `YAJL <http://lloyd.github.com/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 <http://pykler.github.com/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.
Something went wrong with that request. Please try again.