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.
Functions§
- jsonrepair
- Repair a broken JSON string, returning valid JSON.