JSON Writer
Easy package to write JSON files
About
jsonwriter is an easy JSON writer, when i say easy i mean super easy
Made by Nawaf Alqari in 2021
Installation
PIP
pip install jsonwriter
Examples
Initialize your file:
If you set autosave to True every change you make will be automatically saved
from jsonwriter import file
file = file('filename.json', autosave=True)
file.set('key', 'value') # This will be saved automatically
If you don't use autosave you have to add file.save() whenever you want to save your changes
from jsonwriter import file
file = file('filename.json', autosave=False)
file.set('key', 'value')
file.set('key2', 'value2')
file.save() # Now, it will be saved
Functions
Let's say this is our file content:
{
"name": "Nawaf",
"age": 10
}
get(key)
file.get('name') # Will return Nawaf
file.get('age') # Will return 10
set(key, value)
file.set('Skills', ['Sleeping', 'Coding'], indent=3)
# indentation will make it more readable
# 3 is recommended/default value
# set() Can also update values
file.set('age', 100)
File will get updated to
{
"name": "Nawaf",
"age": 100,
"Skills": [
"Sleeping",
"Coding"
]
}
If we set the indentation to 0 this is what we will get
{"name": "Nawaf", "age": 100, "Skills": ["Sleeping", "Coding"]}
remove(key)
file.remove('name') # This will just remove "name": "Nawaf"
clear()
file.clear() # Warning! This will remove everything from your file
hasKey(key)
file.hasKey('age') # return True
hasValue(value)
file.hasValue(10) # return True
hasAll(key or value)
file.hasAll('age') # return True
file.hasAll(10) # return True
Attributes
from jsonwriter import file
file = file('filename.json', autosave=True)
print(file.content)
# This will show your file content
# Note: if you are not using autosave this will show all the changes, even if they are not saved
print(file.keys)
# This will show all the keys
print(file.values)
# This will show all the values
Metadata
Release files for jsonwriter 0.1.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 | |
|---|---|---|---|---|
| jsonwriter-0.1.4.tar.gz | 3.0 kB | Without provenance | Details |
Release files / jsonwriter-0.1.4.tar.gz
| Download URL | jsonwriter-0.1.4.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f720e2938939aab8fe0c7f156873e749aeb2499a57f45cd3dfa33a41242bfaa
|
|
BLAKE2b-256 checksum How to use checksums |
6617656c5b24162549e7a29e0ce09da22dbaf7671f6f485bf2579aef3edb5708
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
|
Security for jsonwriter 0.1.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.