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
thefuzzlibrary
- Open JSON files in the system’s default editor via
EDITORenvironment variable. - Detailed status command to inspect current loaded data.
Prerequisites
- Python 3.6+
- Dependencies:
cmd2tinydbrequeststhefuzzpython-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
cmd2tinydbrequeststhefuzzpython-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!
Metadata
Release files for json-manager-cli 0.1.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| json_manager_cli-0.1.7.tar.gz | 13.5 kB | Without provenance | Details for json_manager_cli-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json_manager_cli-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for json_manager_cli-0.1.7-py3-none-any.whl |
Total release size: 30.2 kB
Release files / json_manager_cli-0.1.7.tar.gz
| Download URL | json_manager_cli-0.1.7.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c270233acbe0b9c0153d2f8600a41debe52abb36f3f925fbafe33853f7b4d81
|
|
BLAKE2b-256 checksum How to use checksums |
05b06c111b4296c3c7f058e902762566cf69dea026246a8051e55608505c814d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.11.7 Windows/10
|
Release files / json_manager_cli-0.1.7-py3-none-any.whl
| Download URL | json_manager_cli-0.1.7-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d2cde3c6ead3037f33fce8d9467ec4749772f549908de28004148a99b13f32f4
|
|
BLAKE2b-256 checksum How to use checksums |
e1ca287063552be7c6aad1a3387f5328437390d9c7541516dfbdcac9ffa04112
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.11.7 Windows/10
|
Security for json-manager-cli 0.1.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.