No project description provided
Project description
JSON Manager
JSON Manager is a command-line interface (CLI) tool for managing JSON files in multiple formats. It provides two distinct consoles for working with JSON data:
- Database Console: Launched when the JSON file is TinyDB‑compatible (i.e. contains a
_defaultkey with a dict value) or when the JSON is a list. This console leverages TinyDB for database-like operations. - JSON Console: Launched for JSON files that do not match the TinyDB format, offering commands for inspecting and modifying standard JSON objects.
The tool also supports downloading JSON data from a URL into a temporary directory and then processing it accordingly.
Features
- Flexible JSON Loading:
Load JSON files from local paths or remote URLs. - Automatic Format Detection:
The tool inspects the JSON structure and automatically selects the appropriate console (database or JSON) based on the format. - Rich Command-Line Interface:
Built on top of cmd2, it offers a variety of commands such as:loadto load a JSON file or URL.insertto add records.searchandfuzzy_searchfor finding records.open_jsonto open the file with your default editor.statusto view the current state of the loaded data.
- TinyDB Integration:
For JSON files in TinyDB format, enjoy database operations with TinyDB. - Customizable Environment:
Leverage environment variables (e.g.,EDITOR) for a personalized setup.
Prerequisites
- Python: 3.6+
- Required Python Libraries:
cmd2tinydbrequeststhefuzzpython-dotenv
Install the required libraries with:
pip install cmd2 tinydb requests thefuzz python-dotenv
Installation
Clone the repository and navigate to the project directory:
git clone <repository_url>
cd json_manager
Project Structure
json_manager/
├── __init__.py
├── db_console.py # CLI for TinyDB-compatible or list JSON files.
├── buffered_cmd2.py # Custom cmd2 subclass for buffered command output.
├── json_console.py # CLI for general JSON files.
└── main.py # Entry point: selects and launches the appropriate console.
Usage
Run the project using the main entry script. The script accepts a required positional argument for the JSON file or URL, and an optional --temp argument for specifying a temporary directory when downloading files:
python main.py <path_or_url_to_json> [--temp <temp_directory>]
Examples
-
Load a local JSON file:
python main.py data/sample.json
-
Download and load a JSON file from a URL (saved to the default
temp/directory):python main.py https://example.com/data.json
-
Specify a custom temporary directory:
python main.py https://example.com/data.json --temp /path/to/temp/
Based on the JSON structure, the tool will automatically launch either the database console or the JSON console. Within these consoles, you can use commands like:
load— Load a new JSON file or URL.insert— Insert new records into the data.searchandfuzzy_search— Find records using exact or fuzzy matching.open_json— Open the current JSON file in your preferred editor.status— Display details about the loaded file and data.
Contributing
Contributions are welcome! If you have suggestions, improvements, or bug fixes, please open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
Enjoy using JSON Manager!
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
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_manager_cli-0.1.0.tar.gz.
File metadata
- Download URL: json_manager_cli-0.1.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.7 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee43ce9e2a02fabc8337d553311e6762d64f18145a382bfcc2e9efce521a5632
|
|
| MD5 |
ccbcf5d189bb1b0a8f4ff32ff075212e
|
|
| BLAKE2b-256 |
f92b668bf6a6ac4a52067d2ff95e723f5506679323859825fa2221c830925b32
|
File details
Details for the file json_manager_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: json_manager_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.7 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95da3f1499b226eeb2ac4f787a7c0d55b36509cf4cf67182c27bd6fa11531b96
|
|
| MD5 |
4527eefc74dda59dcabf2597994f5edd
|
|
| BLAKE2b-256 |
3237e69a1f3b0477c018ae1ac13db970be3457a744225f3662c871b353bf69b3
|