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 hashes)

Uploaded Source

Supported by

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