Metadata-Version: 2.4
Name: quick-json-diff
Version: 1.0.0
Summary: Compare two JSON files quickly using Python standard library.
Author-email: Rainux He <rainuxhe@outlook.com>
License: MIT License
        
        Copyright (c) 2026 Rainux He
        
        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.
        
Project-URL: Homepage, https://github.com/rainuxhe/fastjsondiff
Project-URL: Issues, https://github.com/rainuxhe/fastjsondiff/issues
Project-URL: Documentation, https://github.com/rainuxhe/fastjsondiff#readme
Project-URL: Source, https://github.com/rainuxhe/fastjsondiff
Project-URL: Repository, https://github.com/rainuxhe/fastjsondiff
Keywords: json,diff,compare,cli
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# quick-json-diff

[![Python](https://img.shields.io/badge/python-%3E%3D3.9-blue.svg)](https://www.python.org/)
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
[![PyPI version](https://img.shields.io/pypi/v/quick-json-diff)](https://pypi.org/project/quick-json-diff/)
[![PyPI downloads](https://img.shields.io/pypi/dm/quick-json-diff)](https://pypi.org/project/quick-json-diff/)

A fast JSON diff tool built entirely with the Python standard library — no third-party dependencies required.

Recursively compare two JSON objects and produce a structured list of all differences (added, removed, or modified values), each annotated with a clear dot-notation path.

---

## Features

- **Zero dependencies** — powered by Python standard library only
- **Recursive comparison** — drill into nested dicts and lists automatically
- **Clear path output** — each difference includes a dot-notation / bracket-notation path (e.g., `variables[3].spec.sort`)
- **Three diff kinds** — `added`, `removed`, `modified` for every change
- **CLI + Python API** — use it from the command line or as a library
- **Safe & predictable** — pure Python dataclass output, easy to serialise

---

## Installation

```shell
python -m pip install quick-json-diff
```

---

## Usage

### CLI

```shell
json-diff <left_json_file> <right_json_file>
```

Example:

```shell
json-diff test_left.json test_right.json
```

Output:

```json
[
    {
        "path": "variables[3].spec.sort",
        "kind": "modified",
        "left": "alphabeticalAsc123",
        "right": "alphabeticalAsc"
    }
]
```

### Python API

```python
import json
from quick_json_diff import JsonDiffer

left = JsonDiffer.read_json("test_left.json")
right = JsonDiffer.read_json("test_right.json")
differ = JsonDiffer(left, right)
result = differ.diff()

print(json.dumps(result, ensure_ascii=False, indent=2))
```

You can also work with raw Python objects directly:

```python
from quick_json_diff import JsonDiffer

left = {"a": 1, "b": [1, 2, 3]}
right = {"a": 2, "b": [1, 2, 3, 4], "c": "new"}
differ = JsonDiffer(left, right)
result = differ.diff()

for item in result:
    print(f"{item['kind']}: {item['path']}")
    if item['left'] is not None:
        print(f"  left:  {item['left']}")
    if item['right'] is not None:
        print(f"  right: {item['right']}")
```

Output:

```
modified: a
  left:  1
  right: 2
added: c
  right: new
added: b[3]
  right: 4
```

---

## Output Format

`differ.diff()` returns a `list[dict]`. Each dict has the following keys:

| Key     | Type                                      | Description                            |
|---------|-------------------------------------------|----------------------------------------|
| `path`  | `str`                                     | Dot/bracket-notation path to the value |
| `kind`  | `"added"` / `"removed"` / `"modified"`    | Type of change                         |
| `left`  | `Any` (optional)                          | Original value (present for `removed` / `modified`) |
| `right` | `Any` (optional)                          | New value (present for `added` / `modified`) |

The same shape is available as the `DiffResult` dataclass:

```python
from quick_json_diff import DiffResult

result: DiffResult  # .path, .kind, .left, .right
```

---

## Contributing

Contributions are welcome! Here's how you can help:

1. **Report issues** — open a [GitHub Issue](https://github.com/rainuxhe/fastjsondiff/issues) for bugs or feature requests
2. **Submit pull requests** — fork the repo, make changes, and open a PR
3. **Development setup**:
   ```shell
   git clone https://github.com/rainuxhe/fastjsondiff.git
   cd quick-json-diff
   pip install -e ".[dev]"
   python -m build
   ```

Before submitting, please ensure the existing tests pass and add tests for new functionality.

---

## License

[MIT](LICENSE) © 2026 Rainux He
