json-fix 0.1.1

Robust JSON repair engine for fixing malformed or partial JSON strings, especially from AI output
Documentation
[![Crates.io](https://img.shields.io/crates/v/json-fix.svg)](https://crates.io/crates/json-fix)
[![Docs.rs](https://docs.rs/json-fix/badge.svg)](https://docs.rs/json-fix)

# πŸ› οΈ json-fix

**json-fix** is a blazing-fast, Rust-powered JSON repair library built for resilient data pipelines, GPT outputs, web scraping tools, and any system where malformed JSON sneaks in.

It detects and fixes broken JSON strings β€” from misescaped quotes to missing commas β€” using a curated sequence of regex-powered healing steps. Ideal for both CLI tools and backend services.

---

## πŸš€ Features

- βœ… Fixes unescaped or invalid quote issues
- βœ… Repairs trailing commas, missing brackets, and embedded key-value bugs
- βœ… Pure Rust β€” no unsafe, no dependencies outside `fancy-regex`
- βœ… Supports logs for each fix step
- βœ… Battle-tested against AI-generated JSON errors
- βœ… Easily embeddable as a library or CLI tool

---

## πŸ§ͺ Example

```rust
use json_fix::fix_json_syntax;

fn main() {
    let broken = r#"{ "name": "Momo, "age": 3 }"#;
    let result = fix_json_syntax(broken);

    if result.fixed != broken {
        println!("βœ… Fixed JSON:\n{}", result.fixed);
    } else {
        println!("⚠️ No changes made.");
    }
}
```

---

## πŸ“‚ Usage

### Install:

```bash
cargo add json-fix
```

### As a library:

```rust
let result = fix_json_syntax(broken);
```

### From CLI:

```bash
cargo run --example quick_fix
```

---

## πŸ“Š Benchmarks

Run:

```bash
cargo bench
```

---

## πŸ“ Project Structure

- `src/lib.rs` – Public-facing API
- `src/fixer.rs` – Core fix logic (regex-powered)
- `examples/quick_fix.rs` – Minimal usage demo
- `tests/fixer.rs` – Real-world test case
- `benches/fix_benchmark.rs` – Criterion benchmarks

---

## βš–οΈ License

MIT – In shāʾ Allāh, may it be a source of barakah for those who use and improve it.