Skip to main content

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

Importing the Library

from json_toolkit import JSONToolkit

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)

Removing Key JSON Elements

  • Remove a key-value pair from the JSON data.
# Remove a key-value pair
JSONToolkit.remove_key(json_file_path, 'key')

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.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

json_toolkit-0.2.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file json-toolkit-0.2.2.tar.gz.

File metadata

  • Download URL: json-toolkit-0.2.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for json-toolkit-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f6d56ded6924cd6c2a834efaf981d9609ab1d786f20386fc5a4e21008ab3c2b7
MD5 019360d468253e4edf5d4b45d5302bab
BLAKE2b-256 2e4fdfcab0831f35edb64b255f6f0a142245b6d97838b7ab145ef74a15ba60ca

See more details on using hashes here.

File details

Details for the file json_toolkit-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: json_toolkit-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.13

File hashes

Hashes for json_toolkit-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 12696f0b6e5faf78ad5a52b5c3d9e2d0f565b340b4a49148dfe72a59f9a3c173
MD5 800d6a7e77d336a08c6c8364a3714052
BLAKE2b-256 afd4c6f7f21d0199747e6182715d2fd26e17da549ff2d69d6a800390de66546b

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