A simple library for JSON manipulation
Project description
JSONToolkit
JSON Toolkit
JSONToolkit is a simple Python library for manipulating JSON files. It allows you to convert JSON files between one-line and multi-line formats easily, as well as add various types of key-value pairs to your JSON data.
Features
JSON Conversion
- Convert a JSON file to a single-line JSON string.
# Convert JSON to one-line format
JSONToolkit.convert(json_file_path, 'to-oneline')
- Convert a single-line JSON string back to a multi-line JSON format.
# Convert JSON back to multi-line format
JSONToolkit.convert(json_file_path, 'from-oneline')
Adding Key JSON Elements
- Add a key-value pair to the JSON data.
# Add a key-value pair
JSONToolkit.add_key_value(json_file_path, 'key', value)
- Add a JSON object (dictionary).
# Add a JSON object
JSONToolkit.add_object(json_file_path, 'key', {"nested_key": "nested_value"})
- Add a string value.
# Add a string value
JSONToolkit.add_string(json_file_path, 'key', 'string_value')
- Add a number (integer or float).
# Add a number
JSONToolkit.add_number(json_file_path, 'key', 123)
# or
JSONToolkit.add_number(json_file_path, 'key', 123.45)
- Add a JSON array (list).
# Add a JSON array
JSONToolkit.add_array(json_file_path, 'key', [1, 2, 3])
- Add a null value.
# Add a null value
JSONToolkit.add_null(json_file_path, 'key')
- Add a boolean value.
# Add a boolean value
JSONToolkit.add_bool(json_file_path, 'key', True)
# or
JSONToolkit.add_bool(json_file_path, 'key', False)
Installation
You can install the library using pip:
pip install json-toolkit
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
json-toolkit-0.2.0.tar.gz
(3.1 kB
view details)
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 json-toolkit-0.2.0.tar.gz.
File metadata
- Download URL: json-toolkit-0.2.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c248ff56f530375713a13bae818490ccbf23890180b42555c4661e38fb59fe0
|
|
| MD5 |
6914cff1130d76ee2e3db5451ec66826
|
|
| BLAKE2b-256 |
c3629ac0b0d338956a8248fc17e902f93d385172171f2dfe95f8f2c2e4181ed1
|
File details
Details for the file json_toolkit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: json_toolkit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffcbc747ebabcbb624d2d4490193e74c347ef5773ec7f9b98a1cb88f6c6f45e7
|
|
| MD5 |
7ef632571796a9a14635aac4393c8c44
|
|
| BLAKE2b-256 |
6174e4a6e36f03f34064c8834d2ef8f0222295720805565428fd79577ce75991
|