Skip to main content

Tool for transforming a JSON to another JSON by defining a configuration JSON setting file.

Project description

jsonmorph

jsonmorph is a tool for transforming a JSON to another JSON by defining a configuration JSON setting file.

Features

  • In-built functions to customize the output JSON.
  • Designed for seamlessly transforming JSON to another JSON.
  • Simple and easy-to-use.

Installation

You can install jsonmorph using pip:

pip install jsonmorph

In-built functions

  • To be used as a value in the settings json.
  1. Fixed String: {{string('sample_fixed_string')}}
  2. Current datetime: {{now()}}
  3. NULL value: {{NULL}}

Example Usage

from jsonmorph import process_json

try:
    output_json = process_json("your_fav_directory/input.json", "your_fav_directory/setting.json", "your_fav_directory/output.json")
    print(output_json)
except Exception as e:
    print(f"Error: {e}")

Sample JSON files

  1. input.json : Will contain the original JSON.
{
    "name": "Bidut Karki",
    "address": {
        "street" : "Developers paradise"
    }
}
  1. setting.json : You will have to compose this, using the in build functions and path of the nested values.
{
    "myname" : "name",
    "age": "{{NULL}}",
    "street_add": "address.street",
    "planet":"{{string('Earth')}}",
    "datetime":"{{now()}}"
}
  1. output.json : Will be generated automatically when process_json function is called.
{
    "myname": "Bidut Karki",
    "age": null,
    "street_add": "Developers paradise",
    "planet": "Earth",
    "datetime": "Tue Jun 04 2024 10:54:14 GMT-0000 (UTC)"
}

Testing

  • This is basically for testing the library if you clone it from github and try to add any feature. Otherwise, you don't need it to use the library.
python3 -m unittest jsonmorph/tests/test_main.py

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub repository. License

Contact

Email: bidutjava3@gmail.com Github: https://github.com/karki-03 Website: bidutkarki.com LinkedIn: https://www.linkedin.com/in/bidutkarki/

  • In case, of any bug or any suggestion, do drop a mail or connect with me on linkedin.
jsonmorph is released under the MIT License. See the LICENSE file for more details.

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

jsonmorph-0.0.6.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file jsonmorph-0.0.6.tar.gz.

File metadata

  • Download URL: jsonmorph-0.0.6.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.8.10

File hashes

Hashes for jsonmorph-0.0.6.tar.gz
Algorithm Hash digest
SHA256 bb5f595a4712a42f14cc15144cf788cdfbf3e2360318650c26a071966c542f54
MD5 17ed4ba3e02a2836a7af565e157c1fe1
BLAKE2b-256 1b6f0f41a67637dbf60396136f63a28818d5d825eb238214ed752aae48ad8fd4

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