Skip to main content

No project description provided

Project description

JSON Manager

JSON Manager is a versatile command-line tool for managing JSON files, featuring two specialized console interfaces:

  • DB Console: For JSON files compatible with TinyDB, enabling database-like operations.
  • JSON Console: For general JSON files, offering basic inspection and editing capabilities.

JSON Manager automatically determines the appropriate interface based on the loaded data structure, including support for downloading JSON directly from URLs.


Features

  • Dual-Console Interface:
    • Automatically selects between DB and JSON console based on JSON structure.
  • DB Console supports database operations (insert, search, fuzzy search) via TinyDB.
    • Custom UTF-8 Storage handling for improved compatibility.
    • Automatic JSON format conversion for TinyDB compatibility.
  • Remote JSON Loading: Directly load JSON data from URLs into a local environment.
  • Buffered Command Interface: Enhanced interaction built on cmd2, supporting command history, colorized output, and configurable prompts.
  • Persistent Data Management: Automatic data synchronization to disk after command execution.

Features

  • Load JSON from local files or URLs.
  • Insert new records into JSON lists.
  • Comprehensive search functionalities:
    • Exact match
    • Substring match (case-sensitive and case-insensitive)
    • Regex matching
    • Fuzzy matching using thefuzz library
  • Open JSON files in the system’s default editor via EDITOR environment variable.
  • Detailed status command to inspect current loaded data.

Prerequisites

  • Python 3.6+
  • Dependencies:
    • cmd2
    • tinydb
    • requests
    • thefuzz
    • python-dotenv

Install dependencies with:

pip install cmd2 tinydb requests thefuzz python-dotenv

Project Structure

src/
└── json_manager
    ├── __init__.py
    ├── db_console.py         # TinyDB-based operations
    ├── json_console.py       # General JSON handling
    ├── buffered_cmd2.py      # Enhanced cmd2 console interface
    └── main.py               # Entry point, dynamically selects the console

Usage

Launching the JSON Manager CLI

From the project root directory:

python src/json_manager/main.py [--json <path_or_url>]

Common Commands

  • Load JSON
load <path_or_url>
  • Insert Record (only when data is a list):
insert '{"name": "Alice", "age": 30}'
  • Search Records
search <value> --field <field1> [--contains|--icontains|--regex]
  • Fuzzy Search
fuzzy_search <search_term> --field <field> [--threshold <score>]
  • Open JSON in Editor
open_json
  • Check Status
status

Environment Configuration

Ensure your preferred text editor is set in your environment:

export EDITOR=nano

Custom Storage Handling

The tool uses a custom TinyDB storage class (UTF8ReplaceJSONStorage) to handle UTF-8 decoding errors gracefully, replacing problematic characters to avoid crashes.

Dependencies

  • cmd2
  • tinydb
  • requests
  • thefuzz
  • python-dotenv

Notes

  • The tool automatically determines whether to use DB Console or JSON Console based on the structure of the JSON file.
  • All changes to JSON data are immediately synchronized to disk.

Happy JSON managing!

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.7.tar.gz (13.5 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.7-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: json_manager_cli-0.1.7.tar.gz
  • Upload date:
  • Size: 13.5 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.7.tar.gz
Algorithm Hash digest
SHA256 2c270233acbe0b9c0153d2f8600a41debe52abb36f3f925fbafe33853f7b4d81
MD5 e28c66b03bfe0606bd8af6948159a8cf
BLAKE2b-256 05b06c111b4296c3c7f058e902762566cf69dea026246a8051e55608505c814d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: json_manager_cli-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 16.7 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d2cde3c6ead3037f33fce8d9467ec4749772f549908de28004148a99b13f32f4
MD5 ecedc4246409922fc66dc924955c982f
BLAKE2b-256 e1ca287063552be7c6aad1a3387f5328437390d9c7541516dfbdcac9ffa04112

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