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.
- Fixed String:
{{string('sample_fixed_string')}}
- Current datetime:
{{now()}}
- 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
- input.json : Will contain the original JSON.
{
"name": "Bidut Karki",
"address": {
"street" : "Developers paradise"
}
}
- 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()}}"
}
- 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)