fjson
fjson is a zero-dependency JSON Parser and Fixer. It takes any input and produces valid JSON. No AI involved.
Features
- Deserializes everything by default (root and nested).
- Repairs incomplete JSON by closing missing brackets and strings.
- Normalizes boolean and null values (e.g., True → true, FALSE → false).
- Normalizes numbers (removes trailing zeros, fixes invalid formats).
- Formatting (beautifier).
- Zero external dependencies.
Installation
Add to Cargo.toml:
[]
= "0.1"
API
fix(input: impl Into<String>) -> String
Parse and fix JSON input. Returns formatted, valid JSON.
Examples
Basic Usage
Output:
Truncated Logs
let truncated_log = r#"{"request_id": 123, "status": "success", "data": {"items": [{"id": 1}, {"id": 2}"#;
let fixed = fix;
Nested JSON Deserialization
let nested = r#"{"payload": "{\"user\": \"alice\", \"role\": \"admin\"}"}"#;
let fixed = fix;
Output:
Use Cases
- Truncated logs - Recover valid JSON from log entries that were cut off
- Minified JSON - Beautify compressed JSON
- Partial responses - Handle incomplete API responses
- Data validation - Quick fix for malformed JSON from unreliable sources
License
Copyright © 2025-present, fjson Contributors.
This project is MIT licensed.