import of github code used for the hackathon
[github-barcamp-201407] / ijson-1.1 / PKG-INFO
1 Metadata-Version: 1.1
2 Name: ijson
3 Version: 1.1
4 Summary: Iterative JSON parser with a standard Python iterator interface
5 Home-page: https://github.com/isagalaev/ijson
6 Author: Ivan Sagalaev
7 Author-email: maniac@softwaremaniacs.org
8 License: LICENSE.txt
9 Description: =====
10         ijson
11         =====
12         
13         Ijson is an iterative JSON parser with a standard Python iterator interface.
14         
15         
16         Usage
17         =====
18         
19         All usage example will be using a JSON document describing geographical
20         objects::
21         
22             {
23               "earth": {
24                 "europe": [
25                   {"name": "Paris", "type": "city", "info": { ... }},
26                   {"name": "Thames", "type": "river", "info": { ... }},
27                   // ...
28                 ],
29                 "america": [
30                   {"name": "Texas", "type": "state", "info": { ... }},
31                   // ...
32                 ]
33               }
34             }
35         
36         Most common usage is having ijson yield native Python objects out of a JSON
37         stream located under a prefix. Here's how to process all European cities::
38         
39             import ijson
40         
41             f = urlopen('http://.../')
42             objects = ijson.items(f, 'earth.europe.item')
43             cities = (o for o in objects if o['type'] == 'city')
44             for city in cities:
45                 do_something_with(city)
46         
47         Sometimes when dealing with a particularly large JSON payload it may worth to
48         not even construct individual Python objects and react on individual events
49         immediately producing some result::
50         
51             import ijson
52         
53             parser = ijson.parse(urlopen('http://.../'))
54             stream.write('<geo>')
55             for prefix, event, value in parser:
56                 if (prefix, event) == ('earth', 'map_key'):
57                     stream.write('<%s>' % value)
58                     continent = value
59                 elif prefix.endswith('.name'):
60                     stream.write('<object name="%s"/>' % value)
61                 elif (prefix, event) == ('earth.%s' % continent, 'end_map'):
62                     stream.write('</%s>' % continent)
63             stream.write('</geo>')
64         
65         
66         Backends
67         ========
68         
69         Ijson provides several implementations of the actual parsing in the form of
70         backends located in ijson/backends:
71         
72         - ``yajl2``: wrapper around `YAJL <http://lloyd.github.com/yajl/>`_ version 2.x
73         - ``yajl``: wrapper around `YAJL <http://lloyd.github.com/yajl/>`_ version 1.x
74         - ``python``: pure Python parser (good to use under PyPy)
75         
76         You can import a specific backend and use it in the same way as the top level
77         library::
78         
79             import ijson.backends.python as ijson
80         
81             for item in ijson.items(...):
82                 # ...
83         
84         Importing the top level library as ``import ijson`` tries to import all backends
85         in order, so it either finds an appropriate version of YAJL or falls back to the
86         Python backend if none is found.
87         
88         
89         Acknowledgements
90         ================
91         
92         Python parser in ijson is relatively simple thanks to `Douglas Crockford
93         <http://www.crockford.com/>`_ who invented a strict, easy to parse syntax.
94         
95         The `YAJL <http://lloyd.github.com/yajl/>`_ library by `Lloyd Hilaiel
96         <http://lloyd.io/>`_ is the most popular and efficient way to parse JSON in an
97         iterative fashion.
98         
99         Ijson was inspired by `yajl-py <http://pykler.github.com/yajl-py/>`_ wrapper by
100         `Hatem Nassrat <http://www.nassrat.ca/>`_. Though ijson borrows almost nothing
101         from the actual yajl-py code it was used as an example of integration with yajl
102         using ctypes.
103         
104 Platform: UNKNOWN
105 Classifier: Development Status :: 5 - Production/Stable
106 Classifier: License :: OSI Approved :: BSD License
107 Classifier: Programming Language :: Python :: 2
108 Classifier: Programming Language :: Python :: 3
109 Classifier: Topic :: Software Development :: Libraries :: Python Modules

Benjamin Mako Hill || Want to submit a patch?