Load multiple delimited JSON documents from a single string or file-like object.
Project description
jsonstream
Load multiple delimited JSON documents from a single string or file-like object.
This allows for storing multiple object roots to be stored in a single document,
but without having to load all the object roots from the document at once.
jsonstream
does not even require that you have the entire document
immediately stored in memory. This allows you to stream objects from files
which are too large to store in memory, or from network connections.
Basic Usage
Retrieve objects from the document one at a time, or all at once.
from jsonstream import loads
>>> doc = '[1, 2, 3] {"some": "object"}\n null'
>>> it = loads(doc)
>>> next(it)
[1, 2, 3]
>>> list(it)
[{"some": "object"}, None]
Using file-like objects when the whole document is not immediately available
>>> from jsonstream import load
>>> from io import StringIO
>>> fh = StringIO('["first"] ["second"]')
>>> it = load(fh)
>>> next(it)
["first"]
>>> fh.write('["and", "a", "third"]')
>>> list(it)
[["second"], ["and", "a", "third"]]
Further documentation can be found on the doc strings of loads
and load
.
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
Built Distribution
Hashes for jsonstream-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63f30349d09a7b6fa5f628305914e40b99fe0e6aa303ccadb12fc52ea2c3e74e |
|
MD5 | 7a65569f64043bee3dcc2cef6cad0ad7 |
|
BLAKE2b-256 | 29d1d7df2f3048a5a0ea999ef46ff35a4c42721208f94fac8185f8072756b1aa |