Skip to main content

json-stream-generator - serialize json in generator

tests pypi

json-stream-generator allows you to serialize object to JSON string and start the output immediately, without waiting for serialization to complete.

It was designed to be used with Django's StreamingHttpResponse or similar concept in other web frameworks to allow sending huge json blobs to the client without triggering load balancer's timeout:

from json_stream_generator import json_generator
from django.http import StreamingHttpResponse

def my_view(request):
    # NOTE: No Content-Length header!
    return StreamingHttpResponse(
        json_generator((num for num in range(100_000_000))),
        content_type="application/json",
        headers={"Content-Disposition": 'attachment; filename="somefilename.json"'},
      )

json-stream-generator comes with built-in support for Django Rest Framework:

from json_stream_generator.rest_framework.mixins import StreamingListModelMixin
from rest_framework import viewsets


class DemoViewSet(StreamingListModelMixin, viewsets.ModelViewSet):
    queryset = MyModel.objects.all()
    serializer_class = MySerializer

Metadata

Release files for json-stream-generator 0.2.0

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

Source distribution (sdist)

Source distribution for json-stream-generator 0.2.0
File Size Uploaded Provenance
json-stream-generator-0.2.0.tar.gz 3.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for json-stream-generator 0.2.0
File Interpreter ABI Platform
json_stream_generator-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.5 kB

Release files / json-stream-generator-0.2.0.tar.gz

Download URL json-stream-generator-0.2.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4762e66b77b12180fee124345befa205fd7247fc5dc420e1564b9c1d0b974676
BLAKE2b-256 checksum
How to use checksums
6c76673a465c39989ab75a433f90209ccd4e84550956a261d0bb49368b82543b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release files / json_stream_generator-0.2.0-py3-none-any.whl

Download URL json_stream_generator-0.2.0-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d9a71e2c9483310f6d7cb973ed2264143580c2a8c907d78bccc65d375362f39
BLAKE2b-256 checksum
How to use checksums
0d120a2fb0f0b90a23a699b817bb589149a77ffb6dc2a51e9955271a3213f706
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Security for json-stream-generator 0.2.0

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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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