| Name | jsj JSON |
| Version |
0.3.4
JSON |
| download |
| home_page | None |
| Summary | JavaScript QoL for JSON in python |
| upload_time | 2024-08-10 21:54:29 |
| maintainer | None |
| docs_url | None |
| author | Mark Tobin |
| requires_python | >=3.12 |
| license | None |
| keywords |
|
| VCS |
 |
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# 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
```python
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.
```python
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
```python
# 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
```
Raw data
{
"_id": null,
"home_page": null,
"name": "jsj",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": null,
"author": "Mark Tobin",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/6a/3e/27f45c8d01dec2ea3bf412826ac09c8d8af8df879d06009b061013dd18ca/jsj-0.3.4.tar.gz",
"platform": null,
"description": "# JSJ\nJavaScript QoL for JSON in python.\n## Motivation\nBeing 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.\n## Basic Usage\n```python\nfrom jsj import *\n\nurl = \"https://api.weather.gov/points/39.7632,-101.6483\"\n\ndata = fetch(url) \\\n .json() \\\n .get_data()\n\nassert data.properties.timeZone == \"America/Chicago\"\n```\n\n## Requesting and flattening JSON\nJSJ can flatten JSON documents, just like the `pandas.normalize_json()` function.\n```python\nfrom jsj import *\n# Some sample data\ndata = JSON([\n {\n \"id\": 1,\n \"name\": \"Cole Volk\",\n \"fitness\": {\"height\": 130, \"weight\": 60},\n },\n {\"name\": \"Mark Reg\", \"fitness\": {\"height\": 130, \"weight\": 60}},\n {\n \"id\": 2,\n \"name\": \"Faye Raker\",\n \"fitness\": {\"height\": 130, \"weight\": 60},\n },\n])\n\ndata_flattened, keys = data.flatten()\n\nassert data_flattened[0] == {\n \"id\": 1,\n \"name\": \"Cole Volk\",\n \"fitness_height\": 130,\n \"fitness_weight\": 60,\n}\n```\n\n## Getting the albums released by an artist\n```python\n# Sets the URLs `artist` parameter to Post Malone\nurl = \"https://musicbrainz.org/ws/2/release?artist=b1e26560-60e5-4236-bbdb-9aa5a8d5ee19&type=album|ep&fmt=json\"\n# Fetches, flattens and gets the titles to all releases\nalbums = fetch(url) \\\n .json() \\\n .then(lambda data: data.flatten(base=[\"releases\"])[0]) \\\n .then(lambda data: [item.title for item in data]) \\\n .get_data()\n\nassert {\"Stoney\", \"Hollywood\u2019s Bleeding\", \"beerbongs & bentleys\"}.issubset(albums)\n```\n\n## Installation\nThis package is available on pip\n```\npip install jsj\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "JavaScript QoL for JSON in python",
"version": "0.3.4",
"project_urls": {
"GitHub": "https://github.com/some1and2-XC/jsj",
"Homepage": "https://github.com/some1and2-XC/jsj"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "29bb805c0e492ab04497b393d6be5567c2026b70cd2dd422300d63c5e2085a6e",
"md5": "d767a8ea662b44773447dad2f18eed0a",
"sha256": "80888c4b922eb653b2b7a6eb819be3b0a5f22174e784b38954053892a14d785c"
},
"downloads": -1,
"filename": "jsj-0.3.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d767a8ea662b44773447dad2f18eed0a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 5419,
"upload_time": "2024-08-10T21:54:28",
"upload_time_iso_8601": "2024-08-10T21:54:28.077053Z",
"url": "https://files.pythonhosted.org/packages/29/bb/805c0e492ab04497b393d6be5567c2026b70cd2dd422300d63c5e2085a6e/jsj-0.3.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6a3e27f45c8d01dec2ea3bf412826ac09c8d8af8df879d06009b061013dd18ca",
"md5": "6e6655bf35149e5b7f36bdc2439eef54",
"sha256": "720017d0777c1cf1de98275e073a4f2e7a50c7b2adf1525d58b6fdbce8f0d1a6"
},
"downloads": -1,
"filename": "jsj-0.3.4.tar.gz",
"has_sig": false,
"md5_digest": "6e6655bf35149e5b7f36bdc2439eef54",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 6169,
"upload_time": "2024-08-10T21:54:29",
"upload_time_iso_8601": "2024-08-10T21:54:29.349275Z",
"url": "https://files.pythonhosted.org/packages/6a/3e/27f45c8d01dec2ea3bf412826ac09c8d8af8df879d06009b061013dd18ca/jsj-0.3.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-10 21:54:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "some1and2-XC",
"github_project": "jsj",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "jsj"
}