Skip to main content

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 _default key 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:
    • load to load a JSON file or URL.
    • insert to add records.
    • search and fuzzy_search for finding records.
    • open_json to open the file with your default editor.
    • status to 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:
    • cmd2
    • tinydb
    • requests
    • thefuzz
    • python-dotenv

You can install the required libraries using either of the following methods:

  • Using a requirements file:

    pip install -r requirements.txt
    
  • Using pip from PyPI:

    pip install json-manager-cli
    

Installation

Clone the repository and navigate to the project directory if you prefer the source:

git clone <repository_url>
cd json_manager

Alternatively, you can install the CLI directly from PyPI using:

pip install json-manager-cli

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

Running the CLI

After installation, you have two options for running JSON Manager:

  1. Directly via Python:

    python main.py <path_or_url_to_json> [--temp <temp_directory>]
    
  2. Using the jsoncli command (if installed from PyPI):

    jsoncli <path_or_url_to_json> [--temp <temp_directory>]
    

Examples

  • Load a local JSON file:

    jsoncli data/sample.json
    
  • Download and load a JSON file from a URL (saved to the default temp/ directory):

    jsoncli https://example.com/data.json
    
  • Specify a custom temporary directory:

    jsoncli 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.
  • search and fuzzy_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

json_manager_cli-0.1.4.tar.gz (13.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_manager_cli-0.1.4-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file json_manager_cli-0.1.4.tar.gz.

File metadata

  • Download URL: json_manager_cli-0.1.4.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.7 Windows/10

File hashes

Hashes for json_manager_cli-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c25174e759ddd9514448cacb93a1f7d80d9fc375594b6f4c63803b05564d9706
MD5 43db6c515e9f0233998535820ec09427
BLAKE2b-256 ad8b6cd9c473ab4d95957642975a9d81c4bbe3c482c44e2eb77f07a328f963c5

See more details on using hashes here.

File details

Details for the file json_manager_cli-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: json_manager_cli-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.11.7 Windows/10

File hashes

Hashes for json_manager_cli-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 21bff6fb3df3c4f0aafa33505d63c097a08656f2d2e380701633e4da4a503999
MD5 5ffc864bfe1a09ba021a5d20d560cba7
BLAKE2b-256 a7057ca7689234dd41292a77a9df8a077c2911bcb39f52f2913eef6cca92b9e7

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