No project description provided
Project description
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.
Project details
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
File details
Details for the file adafruit_circuitpython_json_stream-0.8.4.tar.gz
.
File metadata
- Download URL: adafruit_circuitpython_json_stream-0.8.4.tar.gz
- Upload date:
- Size: 32.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7276854f8a889eb9f8aece20a134deac1b6b6ff947afb58b2c4563c7e8e78eed |
|
MD5 | a188a157566bedb8aa964c8223ad2d0b |
|
BLAKE2b-256 | 6f7015e0fcc7d57d6dfb9446e79b889561e8ef334dd4f07e46341912be121e60 |
File details
Details for the file adafruit_circuitpython_json_stream-0.8.4-py3-none-any.whl
.
File metadata
- Download URL: adafruit_circuitpython_json_stream-0.8.4-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0789bd966674d9b864757317639ec5ab51c6f89da837b56265692ec40edad0af |
|
MD5 | d511bdd05d33a734983f1b0fdad44b39 |
|
BLAKE2b-256 | d0f9a94f8054d7f868bff37ed72e1f56439545ca37a35c815573988f0f23667f |