Skip to main content

removing all the open(file, 'w') hassle from saving a simple json

Project description

QuickJSON

QuickJSON is a python library that focuses on removing the open(file, 'w') hassle from your daily json file saving needs

Installation

Use the package manager pip to install the package.

pip install QuickJSON

Usage

Import the package to use it.

import QuickJSON


Create a new QJSON object. (everything after the "path" parameter will handed over to the dict super call.

settings = QuickJSON.QJSON('path/to/json.json')

The object will behave like a normal python dictionary.

With following method all of the information stored inside the json file at the before given path will be stored in the current QJSON object. Items that are already stored in the object wont be deleted. They will only be overwritten if you set no_override to False (by default set to False).

settings.load(no_override=False)


Storing data works exactly like a normal python dictionary.

settings['a key'] = 'a value'


Once you are done you can save the QJSON object to the previus path with the following command:

settings.save()


You can also clear move or copy the JSON file by invoking one of the following functions:

settings.copy_save('new/directory/for/json.json')
settings.merge_save('new/directory/for/json.json')
settings.clear_save()

The functions do not modify the content of the dictionary itself, but modify the to file saved content, so make sure to save before copying or moving anything. .clear_save and .move_save will also remove any empty folders left behind


.save(), .load(), .move_save() and .copy_save will automatically check if any given directory is valid. They will generate any missing directories and files if necessary and return an empty dictionary if file is not found or corrupt.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate. (i know, the tests folder is currently empty, but will change soon... hopefully)

License

No License (yey)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

QuickJSON-nicky-0.0.4.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

QuickJSON_nicky-0.0.4-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file QuickJSON-nicky-0.0.4.tar.gz.

File metadata

  • Download URL: QuickJSON-nicky-0.0.4.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for QuickJSON-nicky-0.0.4.tar.gz
Algorithm Hash digest
SHA256 de2e3fcfb379e9c7188bfcab02b180c123ecbdb916aee89b3012b2192e1510b9
MD5 ca390ae9b59d349e6223eb9d8b6afec8
BLAKE2b-256 00cb665e83aed279fd1d4860cd78a9fe6eedc215bd92d439382db54dc08f06cd

See more details on using hashes here.

File details

Details for the file QuickJSON_nicky-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for QuickJSON_nicky-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2242760e10b3c4140e481e68b9ebf110ba0371eb9ab3d14c4c7f0389286ecbca
MD5 9a590f24693f8834fc49722a0f942874
BLAKE2b-256 f7bb25c5aa2eb807c4218c54717eca0bc7968d9d745bd52e618e19edd5de9eda

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page