Skip to main content

StreamJSON

PyPI - Python Version PyPI PyPI - License

tests

Write objects or arrays to a JSON file using a stream. Useful for when you don't want to read large amounts of data in memory, for example when you need to save large amounts of data from a database to a single JSON file.

Read objects from a JSON file using a stream. Does not require loading the whole JSON file in memory.

Install

pip install streamjson

How to write to JSON file

Fetch data from a database or anywhere else and send to a JSON file. The send function takes in a dictionary or a list. A new file with the given name will be created, the root of the JSON file is an array by default.

from streamjson import StreamJSONWriter

persons = [{'id': '0001', 'first_name': 'John', 'last_name': 'Doe'},
           {'id': '0002', 'first_name': 'Jane', 'last_name': 'Doe'}]

with StreamJSONWriter('persons.json', indent=2) as writer:
    for person in persons:
        writer.send(person)

persons.json:

[
  {
    "id": "0001",
    "first_name": "John",
    "last_name": "Doe"
  },
  {
    "id": "0002",
    "first_name": "Jane",
    "last_name": "Doe"
  }
]

How to read from JSON file

The reader will stream each object from the JSON file.

from streamjson import StreamJSONReader

with StreamJSONReader('persons.json') as reader:
    for obj in reader.find():
        print(obj)

Metadata

Release files for streamjson 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamjson 1.0.4
File Size Uploaded Provenance Actions
streamjson-1.0.4.tar.gz 5.6 kB Without provenance Details for streamjson-1.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for streamjson 1.0.4
File Interpreter ABI Platform Actions
streamjson-1.0.4-py3-none-any.whl Python 3 none any Details for streamjson-1.0.4-py3-none-any.whl

Total release size: 12.3 kB

Release files / streamjson-1.0.4.tar.gz

Download URL streamjson-1.0.4.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
be80d88fb925349f821e9876546d3d81361d984253890cd081898ee7eeadd3eb
BLAKE2b-256 checksum
How to use checksums
124a950de5709ed1289fe86c6616e1c8dcf61321ccdd917e58aeffebc13be52b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / streamjson-1.0.4-py3-none-any.whl

Download URL streamjson-1.0.4-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cffe1bbf6560432d55ca40dd3524a1cea95b7a67a375b5c24e6956f8ad58f49d
BLAKE2b-256 checksum
How to use checksums
f949e5af4a6fa0a6f3fc99a78a90dfbc7c5ac89815d0d1adecd656c3a635721e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for streamjson 1.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page