SyJson - Sync variables to a json file in a simple way
What this library do?
This library make simple create a json file and read/write directly from this. This can be very useful and easy to use when we need to create small files such as a settings file, avoiding to write and read this manualy.
How to Install
You can install this library using PyPi (pip)
Linux / Windows / MacOs
pip3 install syjson
How to use
At first you can import SyJson class writing:
from syjson import SyJson
now we can use this class for create/read a json file pretty:int=None, bson:bool=False, cache:bool = True
synced_json = SyJson(
"file.json", #Path of the json file
create_file = True, #If the file does not exists,
#this will automatically create that file
pretty = None, #If setted to a number, the file will have an
#indentation of 'pretty' spaces
cache = True, #The file is readed only the first time with this option set to
#True, if your file have to be modified during the execution set this to false
#(Useful for debugging)
encoding = "utf-8" #JSON file encoding
)
This library use orjson for load and dump json files
There are some particular function added for particular use
--> synced_json.var()
With var function we can read from file the informations and we get a normal python object, so this python object have to be synced in a next step
--> synced_json.sync( value )
With sync function you can assign a variable and sync these informations in the target file
All SyJson object have these functionalityes
In Synced dicts there is an additional function that can be usefull in a lot of situation
--> synced_json.create( key, default_value )
This function create a pair of key and value if that key is not used in the json file and return the synced object, instead this function will simply return the synced object without overriding existing values.
Can bypass the use of sync function when you assign a value to a synced array of a synced dict in the json
f = SyJson("/path/to/file.json")
f["dict"] = {"num":0}
f["list"] = [1]
#Some operation that you can do without using sync function
f["dict"]["num"] = 1
f["dict"].keys()
f["dict"].values()
f["dict"].items()
f["list"][0] = 0
f["list"].append(1)
f["list"].pop()
f["list"].index(0)
By DomySh - me@domysh.com
--> https://domysh.com <--
Metadata
Release files for syjson 2.1.6
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 | |
|---|---|---|---|---|
| syjson-2.1.6.tar.gz | 4.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| syjson-2.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.4 kB
Release files / syjson-2.1.6.tar.gz
| Download URL | syjson-2.1.6.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5d988515c5e974d14ad1f6af0e3f63bdf774e3c2157e5ff4fdb1cf536ca346c9
|
|
BLAKE2b-256 checksum How to use checksums |
db2f8691daa1a719da6c3fb5e72c6864137fc9caab7f9443c400b15058564b6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / syjson-2.1.6-py3-none-any.whl
| Download URL | syjson-2.1.6-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee991fc1c82e7c301fa655cdbbcc7499c2428a575bc33553c904db9f761c173a
|
|
BLAKE2b-256 checksum How to use checksums |
c6595b297dd8c005078504cb49b9a29359e16862803101697c9d21c80b6206c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for syjson 2.1.6
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.