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.1.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.1.tar.gz.
File metadata
- Download URL: json-toolkit-0.2.1.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 |
ce5565947dbd58c31efadb4056f0122473fd4ba4a813fcc24f379d32157ade35
|
|
| MD5 |
55403ac5e441512baf6a439401ac0508
|
|
| BLAKE2b-256 |
b924613bc0b488049d95d56d38297c84a51575e3a2b1f0c1cb83be33604d3bd6
|
File details
Details for the file json_toolkit-0.2.1-py3-none-any.whl.
File metadata
- Download URL: json_toolkit-0.2.1-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 |
e62409ef5940514b795b117e08fcaa4321934d9cc47a42c699c1a388c892c6bd
|
|
| MD5 |
41f5df6e77b4550de54a137816f25dd6
|
|
| BLAKE2b-256 |
10ebc00c1d9f5f43788610a1ededb79e3ed8995817bb8df32b2f21ccdab7d2a2
|