Name | jsonmore JSON |
Version |
1.0.3
JSON |
| download |
home_page | None |
Summary | A powerful command-line tool for reading, formatting, and analyzing JSON files with beautiful syntax highlighting, automatic error repair, and smart paging |
upload_time | 2025-07-15 03:29:47 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | MIT License
Copyright (c) 2025 Jason Cox
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. |
keywords |
cli
formatting
json
repair
syntax-highlighting
validator
|
VCS |
 |
bugtrack_url |
|
requirements |
colorama
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# jsonMore
A command-line tool for reading, formatting, and analyzing JSON files with syntax highlighting, automatic error repair, and smart paging.
[](https://badge.fury.io/py/jsonmore)
[](https://www.python.org/downloads/)
[](https://opensource.org/licenses/MIT)
## Quick Start 🚀
After installation, use the `jsonmore` command directly:
```bash
# Install
pip install jsonmore
# Pipe Test
echo '{"id": 123, "name": "Jason", "nerd": true}' | jsonmore
# File Test
jsonmore somefile.json
```
<img width="452" alt="image" src="https://github.com/user-attachments/assets/1a071f4c-f068-4190-89e0-9eb9ddfe9e37" />
## Installation
### For Users (Recommended)
Install globally using your preferred Python package manager:
```bash
# Using pip
pip install jsonmore
# Using pipx (recommended for CLI tools)
pipx install jsonmore
# Using uv
uv pip install jsonmore
```
### For Developers
Clone the repository and install in development mode:
```bash
git clone https://github.com/yourusername/jsonmore.git
cd jsonmore
pip install -e ".[dev]"
```
## Usage
### Command Line Interface
```bash
# Basic file reading
jsonmore file.json
# Large files with custom size limit
jsonmore large_file.json --max-size 100
# Disable paging for direct output
jsonmore file.json --no-pager
# Handle malformed JSON
jsonmore broken.json # Auto-repair (default)
jsonmore broken.json --no-repair # Disable auto-repair
# Custom formatting
jsonmore file.json --indent 4 --no-colors
```
### Command Line Options
| Option | Description |
|--------|-------------|
| `--no-colors` | Disable color output for plain text |
| `--max-size N` | Maximum file size in MB (default: 50) |
| `--indent N` | Indentation spaces (default: 2) |
| `--no-pager` | Disable automatic paging |
| `--no-repair` | Disable automatic JSON repair |
| `--verbose` | Show headers and JSON structure info |
| `--help` | Show help message and examples |
### Python API
You can also use jsonmore as a Python library:
```python
from jsonmore import JSONReader, JSONFormatter
# Read and parse JSON file
reader = JSONReader()
result = reader.read_file('data.json')
if result['status'] == 'valid':
data = result['data']
print(f"Successfully parsed JSON with {len(data)} keys")
# Format JSON with colors
formatter = JSONFormatter(use_colors=True, indent=2)
formatted = formatter.format_json(data)
print(formatted)
```
## 🔧 JSON Repair Capabilities
The tool can automatically detect and fix common JSON syntax errors:
### **Supported Repairs**
- **Missing quotes** around object keys
- **Single quotes** instead of double quotes
- **Trailing commas** in objects and arrays
- **Missing commas** between properties
- **JavaScript-style comments** (`//` and `/* */`)
- **Missing braces** in nested objects
- **Malformed structure** patterns
### **Example Repairs**
**Before (broken JSON):**
```json
{
name: "John", // Missing quotes on key
'age': 25, // Single quotes
"skills": ["Python",], // Trailing comma
"active": true, // Trailing comma
}
```
**After (auto-repaired):**
```json
{
"name": "John",
"age": 25,
"skills": ["Python"],
"active": true
}
```
## Package Structure
For developers and contributors, here's the package organization:
```
jsonmore/
├── __init__.py # Package initialization and public API
├── cli.py # Command-line interface entry point
├── colors.py # ANSI color definitions
├── core.py # Core JSON processing (JSONReader, JSONFormatter, JSONRepair)
├── utils.py # Utility functions (paging, terminal handling)
└── py.typed # Type hints marker file
```
### Module Overview
- **`jsonmore.cli`**: Command-line interface and argument parsing
- **`jsonmore.core`**: Main business logic for JSON reading, formatting, and repair
- **`jsonmore.colors`**: ANSI color code definitions for terminal output
- **`jsonmore.utils`**: Utility functions for paging and terminal interaction
- **`jsonmore`**: Public API exports for library usage
## Development API
### Setting Up Development Environment
```bash
# Clone the repository
git clone https://github.com/yourusername/jsonmore.git
cd jsonmore
# Install in development mode with dev dependencies
pip install -e ".[dev]"
# Install development tools
pip install -r requirements-dev.txt
```
### Running Tests
```bash
# Basic tests
python test_jsonmore.py
# With pytest (if installed)
pytest test_jsonmore.py -v
```
### Code Quality
```bash
# Format code
black jsonmore/
# Lint code
flake8 jsonmore/
# Type checking
mypy jsonmore/
```
## Error Handling
The tool provides multiple levels of error handling:
1. **Valid JSON**: Normal parsing and display
2. **Auto-Repair**: Attempts to fix common errors
3. **Partial Parsing**: Extracts valid JSON fragments
4. **Raw Display**: Shows content with error highlighting
### Color-Coded Output
- **Keys**: Cyan
- **Strings**: Green
- **Numbers**: Yellow
- **Booleans**: Magenta
- **Null**: Gray
- **Brackets/Braces**: White
### Error Highlighting
```json
{
"name": "John",
â–ºaâ—„ge: 30, // Error highlighted here
"city": "NYC"
}
```
## Contributing
We welcome contributions! Here's how to get started:
1. **Fork the repository** on GitHub
2. **Create a feature branch**: `git checkout -b feature-name`
3. **Make your changes** and add tests
4. **Run the test suite**: `python test_jsonmore.py`
5. **Submit a pull request**
### Guidelines
- Maintain compatibility with Python 3.8+
- Follow the existing code style (use `black` for formatting)
- Add tests for new features
- Update documentation as needed
## License
MIT License - see [LICENSE](LICENSE) file for details.
## Acknowledgments
- Built with Python's standard library for maximum compatibility
- Inspired by tools like `jq`, `bat`, and `less`
- Thanks to the JSON specification and repair techniques community
---
**Happy JSON reading!**
Raw data
{
"_id": null,
"home_page": null,
"name": "jsonmore",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Jason Cox <jason@jasonacox.com>",
"keywords": "cli, formatting, json, repair, syntax-highlighting, validator",
"author": null,
"author_email": "Jason Cox <jason@jasonacox.com>",
"download_url": "https://files.pythonhosted.org/packages/40/57/2a9ab097f9182609e9c519c3050da82d5b91684364c4e29719dc0f22076e/jsonmore-1.0.3.tar.gz",
"platform": null,
"description": "# jsonMore\n\nA command-line tool for reading, formatting, and analyzing JSON files with syntax highlighting, automatic error repair, and smart paging.\n\n[](https://badge.fury.io/py/jsonmore)\n[](https://www.python.org/downloads/)\n[](https://opensource.org/licenses/MIT)\n\n## Quick Start \ud83d\ude80\n\nAfter installation, use the `jsonmore` command directly:\n\n```bash\n# Install\npip install jsonmore\n\n# Pipe Test\necho '{\"id\": 123, \"name\": \"Jason\", \"nerd\": true}' | jsonmore\n\n# File Test\njsonmore somefile.json\n```\n\n<img width=\"452\" alt=\"image\" src=\"https://github.com/user-attachments/assets/1a071f4c-f068-4190-89e0-9eb9ddfe9e37\" />\n\n## Installation\n\n### For Users (Recommended)\n\nInstall globally using your preferred Python package manager:\n\n```bash\n# Using pip\npip install jsonmore\n\n# Using pipx (recommended for CLI tools)\npipx install jsonmore\n\n# Using uv\nuv pip install jsonmore\n```\n\n### For Developers\n\nClone the repository and install in development mode:\n\n```bash\ngit clone https://github.com/yourusername/jsonmore.git\ncd jsonmore\npip install -e \".[dev]\"\n```\n\n## Usage\n\n### Command Line Interface\n\n```bash\n# Basic file reading\njsonmore file.json\n\n# Large files with custom size limit\njsonmore large_file.json --max-size 100\n\n# Disable paging for direct output\njsonmore file.json --no-pager\n\n# Handle malformed JSON\njsonmore broken.json # Auto-repair (default)\njsonmore broken.json --no-repair # Disable auto-repair\n\n# Custom formatting\njsonmore file.json --indent 4 --no-colors\n```\n\n### Command Line Options\n\n| Option | Description |\n|--------|-------------|\n| `--no-colors` | Disable color output for plain text |\n| `--max-size N` | Maximum file size in MB (default: 50) |\n| `--indent N` | Indentation spaces (default: 2) |\n| `--no-pager` | Disable automatic paging |\n| `--no-repair` | Disable automatic JSON repair |\n| `--verbose` | Show headers and JSON structure info |\n| `--help` | Show help message and examples |\n\n### Python API\n\nYou can also use jsonmore as a Python library:\n\n```python\nfrom jsonmore import JSONReader, JSONFormatter\n\n# Read and parse JSON file\nreader = JSONReader()\nresult = reader.read_file('data.json')\n\nif result['status'] == 'valid':\n data = result['data']\n print(f\"Successfully parsed JSON with {len(data)} keys\")\n\n# Format JSON with colors\nformatter = JSONFormatter(use_colors=True, indent=2)\nformatted = formatter.format_json(data)\nprint(formatted)\n```\n\n## \ud83d\udd27 JSON Repair Capabilities\n\nThe tool can automatically detect and fix common JSON syntax errors:\n\n### **Supported Repairs**\n- **Missing quotes** around object keys\n- **Single quotes** instead of double quotes\n- **Trailing commas** in objects and arrays\n- **Missing commas** between properties\n- **JavaScript-style comments** (`//` and `/* */`)\n- **Missing braces** in nested objects\n- **Malformed structure** patterns\n\n### **Example Repairs**\n\n**Before (broken JSON):**\n```json\n{\n name: \"John\", // Missing quotes on key\n 'age': 25, // Single quotes\n \"skills\": [\"Python\",], // Trailing comma\n \"active\": true, // Trailing comma\n}\n```\n\n**After (auto-repaired):**\n```json\n{\n \"name\": \"John\",\n \"age\": 25,\n \"skills\": [\"Python\"],\n \"active\": true\n}\n```\n\n## Package Structure\n\nFor developers and contributors, here's the package organization:\n\n```\njsonmore/\n\u251c\u2500\u2500 __init__.py # Package initialization and public API\n\u251c\u2500\u2500 cli.py # Command-line interface entry point\n\u251c\u2500\u2500 colors.py # ANSI color definitions\n\u251c\u2500\u2500 core.py # Core JSON processing (JSONReader, JSONFormatter, JSONRepair)\n\u251c\u2500\u2500 utils.py # Utility functions (paging, terminal handling)\n\u2514\u2500\u2500 py.typed # Type hints marker file\n```\n\n### Module Overview\n\n- **`jsonmore.cli`**: Command-line interface and argument parsing\n- **`jsonmore.core`**: Main business logic for JSON reading, formatting, and repair\n- **`jsonmore.colors`**: ANSI color code definitions for terminal output\n- **`jsonmore.utils`**: Utility functions for paging and terminal interaction\n- **`jsonmore`**: Public API exports for library usage\n\n## Development API\n\n### Setting Up Development Environment\n\n```bash\n# Clone the repository\ngit clone https://github.com/yourusername/jsonmore.git\ncd jsonmore\n\n# Install in development mode with dev dependencies\npip install -e \".[dev]\"\n\n# Install development tools\npip install -r requirements-dev.txt\n```\n\n### Running Tests\n\n```bash\n# Basic tests\npython test_jsonmore.py\n\n# With pytest (if installed)\npytest test_jsonmore.py -v\n```\n\n### Code Quality\n\n```bash\n# Format code\nblack jsonmore/\n\n# Lint code\nflake8 jsonmore/\n\n# Type checking\nmypy jsonmore/\n```\n\n## Error Handling\n\nThe tool provides multiple levels of error handling:\n\n1. **Valid JSON**: Normal parsing and display\n2. **Auto-Repair**: Attempts to fix common errors\n3. **Partial Parsing**: Extracts valid JSON fragments\n4. **Raw Display**: Shows content with error highlighting\n\n### Color-Coded Output\n- **Keys**: Cyan\n- **Strings**: Green \n- **Numbers**: Yellow\n- **Booleans**: Magenta\n- **Null**: Gray\n- **Brackets/Braces**: White\n\n### Error Highlighting\n```json\n{\n \"name\": \"John\",\n \u25baa\u25c4ge: 30, // Error highlighted here\n \"city\": \"NYC\"\n}\n```\n\n## Contributing\n\nWe welcome contributions! Here's how to get started:\n\n1. **Fork the repository** on GitHub\n2. **Create a feature branch**: `git checkout -b feature-name`\n3. **Make your changes** and add tests\n4. **Run the test suite**: `python test_jsonmore.py`\n5. **Submit a pull request**\n\n### Guidelines\n\n- Maintain compatibility with Python 3.8+\n- Follow the existing code style (use `black` for formatting)\n- Add tests for new features\n- Update documentation as needed\n\n## License\n\nMIT License - see [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- Built with Python's standard library for maximum compatibility\n- Inspired by tools like `jq`, `bat`, and `less`\n- Thanks to the JSON specification and repair techniques community\n\n---\n\n**Happy JSON reading!**\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 Jason Cox\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "A powerful command-line tool for reading, formatting, and analyzing JSON files with beautiful syntax highlighting, automatic error repair, and smart paging",
"version": "1.0.3",
"project_urls": {
"Bug Tracker": "https://github.com/jasonacox/jsonmore/issues",
"Documentation": "https://github.com/jasonacox/jsonmore#readme",
"Homepage": "https://github.com/jasonacox/jsonmore",
"Repository": "https://github.com/jasonacox/jsonmore.git"
},
"split_keywords": [
"cli",
" formatting",
" json",
" repair",
" syntax-highlighting",
" validator"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "198dcbf3a7a538efc0aadaba826d2ef607383e949a323ec5ea7deee2fd9df1a8",
"md5": "68dbd35cecefaf9b37a77f2ccccc6791",
"sha256": "50f53c4930ce8713c56cbb7f75380251b7e5e4b28ee626b03f587d2499b5e7d7"
},
"downloads": -1,
"filename": "jsonmore-1.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "68dbd35cecefaf9b37a77f2ccccc6791",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 17544,
"upload_time": "2025-07-15T03:29:46",
"upload_time_iso_8601": "2025-07-15T03:29:46.411808Z",
"url": "https://files.pythonhosted.org/packages/19/8d/cbf3a7a538efc0aadaba826d2ef607383e949a323ec5ea7deee2fd9df1a8/jsonmore-1.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "40572a9ab097f9182609e9c519c3050da82d5b91684364c4e29719dc0f22076e",
"md5": "c82622a3cf6afa9319d21df4a24449d5",
"sha256": "d984e50ff3a8fc14e24fbd2295fa7d14c68e829156b9b229f4b382691b14932a"
},
"downloads": -1,
"filename": "jsonmore-1.0.3.tar.gz",
"has_sig": false,
"md5_digest": "c82622a3cf6afa9319d21df4a24449d5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 26143,
"upload_time": "2025-07-15T03:29:47",
"upload_time_iso_8601": "2025-07-15T03:29:47.689136Z",
"url": "https://files.pythonhosted.org/packages/40/57/2a9ab097f9182609e9c519c3050da82d5b91684364c4e29719dc0f22076e/jsonmore-1.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-15 03:29:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "jasonacox",
"github_project": "jsonmore",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "colorama",
"specs": []
}
],
"lcname": "jsonmore"
}