JSJ
JavaScript QoL for JSON in python.
Motivation
Being familiar with Python and with JavaScript, there was something that I just couldn't get over with JavaScript that python just doesn't have, dot notation for json. This library seeks to solve python json issues in a variety of domains.
Basic Usage
from jsj import *
url = "https://api.weather.gov/points/39.7632,-101.6483"
data = fetch(url) \
.json() \
.get_data()
assert data.properties.timeZone == "America/Chicago"
Requesting and flattening JSON
JSJ can flatten JSON documents, just like the pandas.normalize_json() function.
from jsj import *
# Some sample data
data = JSON([
{
"id": 1,
"name": "Cole Volk",
"fitness": {"height": 130, "weight": 60},
},
{"name": "Mark Reg", "fitness": {"height": 130, "weight": 60}},
{
"id": 2,
"name": "Faye Raker",
"fitness": {"height": 130, "weight": 60},
},
])
data_flattened, keys = data.flatten()
assert data_flattened[0] == {
"id": 1,
"name": "Cole Volk",
"fitness_height": 130,
"fitness_weight": 60,
}
Getting the albums released by an artist
# Sets the URLs `artist` parameter to Post Malone
url = "https://musicbrainz.org/ws/2/release?artist=b1e26560-60e5-4236-bbdb-9aa5a8d5ee19&type=album|ep&fmt=json"
# Fetches, flattens and gets the titles to all releases
albums = fetch(url) \
.json() \
.then(lambda data: data.flatten(base=["releases"])[0]) \
.then(lambda data: [item.title for item in data]) \
.get_data()
assert {"Stoney", "Hollywood’s Bleeding", "beerbongs & bentleys"}.issubset(albums)
Installation
This package is available on pip
pip install jsj
Metadata
Release files for jsj 0.3.4
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 |
|---|---|---|---|---|
| jsj-0.3.4.tar.gz | 6.2 kB | Without provenance | Details for jsj-0.3.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jsj-0.3.4-py3-none-any.whl | Python 3 | none | any | Details for jsj-0.3.4-py3-none-any.whl |
Total release size: 11.6 kB
Release files / jsj-0.3.4.tar.gz
| Download URL | jsj-0.3.4.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
720017d0777c1cf1de98275e073a4f2e7a50c7b2adf1525d58b6fdbce8f0d1a6
|
|
BLAKE2b-256 checksum How to use checksums |
6a3e27f45c8d01dec2ea3bf412826ac09c8d8af8df879d06009b061013dd18ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Release files / jsj-0.3.4-py3-none-any.whl
| Download URL | jsj-0.3.4-py3-none-any.whl |
|---|---|
| Size | 5.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80888c4b922eb653b2b7a6eb819be3b0a5f22174e784b38954053892a14d785c
|
|
BLAKE2b-256 checksum How to use checksums |
29bb805c0e492ab04497b393d6be5567c2026b70cd2dd422300d63c5e2085a6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.3
|
Security for jsj 0.3.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.