Load and save json files as a global object
Project description
singlejson
A simple set of utilities for working with JSON in Python.
View the documentation here.
Features:
- Easy loading of JSON files
- One instance for each opened file
- Multiple ways of handling default values
Installation:
Install singlejson using pip
pip install singlejson
Usage:
Loading JSON from a file:
import singlejson
file = singlejson.load('file.json') # Load file.json
# Returns a JSONFile object which has the json property
file.json["fun"] = True # Edit some values in the JSONFile
When we load the same file from the filesystem again, we get the same object:
import singlejson
file2 = singlejson.load('file.json')
print(file2.json["fun"]) # > True
To save the file back to the disk we call file.save()
If the requested file doesn't exist, the file and its parent directories will be created and default_data will be written.
import singlejson
file = singlejson.load('new_file.json', default_data={"fun": False})
print(file.json) # > {"fun": False}
Or initialize the file with a default file path:
import singlejson
file = singlejson.load('auth.json', default_path='defaults/auth.json')
This way you can commit default files to your repository. If the file doesn't exist or is corrupt, the default file will be copied to the requested location.
For more detailed information, visit the documentation
Contributing:
This is just a fun project of mine mainly to try out python packaging. If you would like to contribute or have a feature-request, please open an issue or pull request.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file singlejson-0.4.1.tar.gz.
File metadata
- Download URL: singlejson-0.4.1.tar.gz
- Upload date:
- Size: 84.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89952c3a6a017ac77dd409b10f01049b71bcc6ddc88fdf4cea0a26fcb391cf89
|
|
| MD5 |
bfc881cdad05830830089feba8a33dfc
|
|
| BLAKE2b-256 |
c1d7aa41cc997f2f6cd445738ba1a803d5a3bfc033be27118d2796d0fcf5e784
|
Provenance
The following attestation bundles were made for singlejson-0.4.1.tar.gz:
Publisher:
publish.yml on IgnyteX-Labs/singlejson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
singlejson-0.4.1.tar.gz -
Subject digest:
89952c3a6a017ac77dd409b10f01049b71bcc6ddc88fdf4cea0a26fcb391cf89 - Sigstore transparency entry: 803860757
- Sigstore integration time:
-
Permalink:
IgnyteX-Labs/singlejson@bd0d325af7384065aef27e5e47c269552542f4a2 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/IgnyteX-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bd0d325af7384065aef27e5e47c269552542f4a2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file singlejson-0.4.1-py3-none-any.whl.
File metadata
- Download URL: singlejson-0.4.1-py3-none-any.whl
- Upload date:
- Size: 21.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e84f59761d9d4a0cbbce471febbb9e9cd7d4ab3c50d2ac6e940c6e839f1ca35c
|
|
| MD5 |
a3cca942e7ba97261ab597e29d49cd28
|
|
| BLAKE2b-256 |
a0c20b1397826b0957a20ec459746a45e702dd79441cecb68157e0d903afc807
|
Provenance
The following attestation bundles were made for singlejson-0.4.1-py3-none-any.whl:
Publisher:
publish.yml on IgnyteX-Labs/singlejson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
singlejson-0.4.1-py3-none-any.whl -
Subject digest:
e84f59761d9d4a0cbbce471febbb9e9cd7d4ab3c50d2ac6e940c6e839f1ca35c - Sigstore transparency entry: 803860788
- Sigstore integration time:
-
Permalink:
IgnyteX-Labs/singlejson@bd0d325af7384065aef27e5e47c269552542f4a2 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/IgnyteX-Labs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bd0d325af7384065aef27e5e47c269552542f4a2 -
Trigger Event:
release
-
Statement type: