Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsonstream

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonstream

Load multiple delimited JSON documents from a single string or file-like object.

  • 0.0.1
  • PyPI
  • Socket score

Maintainers
1

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.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc