Introduction
This library is a reimplementation and subset of json_stream. It enables reading JSON data from a stream rather that loading it all into memory at once. The interface works like lists and dictionaries that are usually returned from json.load() but require in-order access. Out of order accesses will lead to missing keys and list entries.
Dependencies
This driver depends on:
Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle or individual libraries can be installed using circup.
Installing from PyPI
This library is on PyPI for editors that use it for CircuitPython. In CPython, it is recommended to use json_stream itself.
Installing to a Connected CircuitPython Device with Circup
Make sure that you have circup installed in your Python environment. Install it with the following command if necessary:
pip3 install circup
With circup installed and your CircuitPython device connected use the following command to install:
circup install adafruit_json_stream
Or the following command to update an existing version:
circup update
Usage Example
import ssl
import time
import adafruit_requests
import socketpool
import wifi
import adafruit_json_stream as json_stream
pool = socketpool.SocketPool(wifi.radio)
session = adafruit_requests.Session(pool, ssl.create_default_context())
SCORE_URL = "http://site.api.espn.com/apis/site/v2/sports/baseball/mlb/scoreboard"
while True:
resp = session.get(SCORE_URL)
json_data = json_stream.load(resp.iter_content(32))
for event in json_data["events"]:
if "Seattle" not in event["name"]:
continue
for competition in event["competitions"]:
for competitor in competition["competitors"]:
print(competitor["team"]["displayName"], competitor["score"])
resp.close()
time.sleep(60)
Documentation
API documentation for this library can be found on Read the Docs.
For information on building library documentation, please check out this guide.
Contributing
Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.
Metadata
Release files for adafruit-circuitpython-json-stream 0.9.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| adafruit_circuitpython_json_stream-0.9.5.tar.gz | 34.3 kB | Without provenance | Details for adafruit_circuitpython_json_stream-0.9.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| adafruit_circuitpython_json_stream-0.9.5-py3-none-any.whl | Python 3 | none | any | Details for adafruit_circuitpython_json_stream-0.9.5-py3-none-any.whl |
Total release size: 40.6 kB
Release files / adafruit_circuitpython_json_stream-0.9.5.tar.gz
| Download URL | adafruit_circuitpython_json_stream-0.9.5.tar.gz |
|---|---|
| Size | 34.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b29c65f9a5ed56b4ef384a9e0a16576e7873782b7db4f89a9fd43467a34cb875
|
|
BLAKE2b-256 checksum How to use checksums |
252afcdfd719916b0f2d23aab8623de62e80a9a9e031a6e5cbd5d353a8371eb5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / adafruit_circuitpython_json_stream-0.9.5-py3-none-any.whl
| Download URL | adafruit_circuitpython_json_stream-0.9.5-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
190b4d3c9517107aa0f03867220eae050cc3c9c9baa4e9f0b066937204095c01
|
|
BLAKE2b-256 checksum How to use checksums |
6654a0854be3257074ec6059e9e8460049f78f64bc81db50d7d58931a58e4d41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for adafruit-circuitpython-json-stream 0.9.5
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.