A JSON streaming writer
Project description
JSONStreams
===========
.. image:: https://travis-ci.org/dcbaker/jsonstreams.svg?branch=master
:target: https://travis-ci.org/dcbaker/jsonstreams
.. image:: https://ci.appveyor.com/api/projects/status/ocrt9nol8kn3pm1t/branch/master?svg=true
:target: https://ci.appveyor.com/project/dcbaker/jsonstreams
Source code is available at `github <https://github.com/dcbaker/jsonstreams>`_.
Documentation is available at `readthedocs <https://jsonstreams.readthedocs.io/>`_.
The code is licensed MIT. See the included LICENSE file for the exact terms.
Description
###########
.. include:: docs/source/description.rst
Basic Usage
###########
A simple use looks like this
.. code-block:: python
with jsonstreams.Stream('foo', 'object') as s:
s.write('foo', 'bar')
with s.subobject('a') as a:
a.write(1, 'foo')
a.write(2, 'bar')
s.write('bar', 'foo')
Writing into a closed group will raise an exception, which should not be
handled, this exception is always an error in programming and should be
corrected.
It is possible to write any value that the encoder (json.JSONEncoder by
default) can encode, so iterating over lists or dictionaries to write them in
is unnecessary
.. code-block:: python
mylist = list(range(10))
mydict = {a, b, for a in range(10), for b in 'abcdefghij'}
with jsonstreams.Stream('foo', 'object') as s:
s.write('list', mylist)
s.write('dict', mydict)
===========
.. image:: https://travis-ci.org/dcbaker/jsonstreams.svg?branch=master
:target: https://travis-ci.org/dcbaker/jsonstreams
.. image:: https://ci.appveyor.com/api/projects/status/ocrt9nol8kn3pm1t/branch/master?svg=true
:target: https://ci.appveyor.com/project/dcbaker/jsonstreams
Source code is available at `github <https://github.com/dcbaker/jsonstreams>`_.
Documentation is available at `readthedocs <https://jsonstreams.readthedocs.io/>`_.
The code is licensed MIT. See the included LICENSE file for the exact terms.
Description
###########
.. include:: docs/source/description.rst
Basic Usage
###########
A simple use looks like this
.. code-block:: python
with jsonstreams.Stream('foo', 'object') as s:
s.write('foo', 'bar')
with s.subobject('a') as a:
a.write(1, 'foo')
a.write(2, 'bar')
s.write('bar', 'foo')
Writing into a closed group will raise an exception, which should not be
handled, this exception is always an error in programming and should be
corrected.
It is possible to write any value that the encoder (json.JSONEncoder by
default) can encode, so iterating over lists or dictionaries to write them in
is unnecessary
.. code-block:: python
mylist = list(range(10))
mydict = {a, b, for a in range(10), for b in 'abcdefghij'}
with jsonstreams.Stream('foo', 'object') as s:
s.write('list', mylist)
s.write('dict', mydict)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsonstreams-0.3.2.tar.gz
(7.6 kB
view hashes)
Built Distribution
Close
Hashes for jsonstreams-0.3.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4bd0ac17993eed8f32ab65d06cc1b9d8f9f92f92c11b4bb9fefb04931dbf791 |
|
MD5 | b1baa62a30f75ce5c549e5ad6318c2ca |
|
BLAKE2b-256 | 9a567f2fc8c1a55f2dca89f954c56602a636b352cd903b09a515f9713278d1ca |