Expand description
§jsonrepair-rs
Repair broken JSON — fix quotes, commas, comments, trailing content, and 30+ other issues commonly found in LLM outputs.
Port of the JavaScript jsonrepair library.
§Usage
use jsonrepair_rs::jsonrepair;
// Fix single quotes (whitespace preserved)
let result = jsonrepair("{'name': 'John'}").unwrap();
assert_eq!(result, r#"{"name": "John"}"#);
// Fix trailing commas
let result = jsonrepair(r#"{"a": 1, "b": 2,}"#).unwrap();
assert_eq!(result, r#"{"a": 1, "b": 2}"#);
// Convert Python keywords
let result = jsonrepair(r#"{"flag": True, "value": None}"#).unwrap();
assert_eq!(result, r#"{"flag": true, "value": null}"#);Structs§
- Json
Repair Error - Error returned when JSON cannot be repaired.
Enums§
- Json
Repair Error Kind - Category of JSON repair error for programmatic handling.
- Json
Repair Stream Error - Error returned by reader-to-writer repair helpers.
- Json
Repair Write Error - Error returned by writer-based repair helpers.
Functions§
- jsonrepair
- Repair a broken JSON string, returning valid JSON.
- jsonrepair_
reader_ to_ writer - Repair JSON-like text from a reader and write valid JSON to a writer.
- jsonrepair_
to_ writer - Repair a broken JSON string and write the valid JSON to a writer.