mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-10-30 14:49:14 +00:00
13 lines
413 B
TypeScript
13 lines
413 B
TypeScript
import {completeJson} from './completeJson';
|
|
import {evaluateJson} from './evaluateJson';
|
|
|
|
/**
|
|
* Takes an incomplete JSON string, and returns a hopefully valid JSON string.
|
|
* Note that this _can_ fail, so you should check the return value is valid JSON.
|
|
*/
|
|
export function fixJson(incompleteJson: string): string {
|
|
const stack = evaluateJson(incompleteJson);
|
|
|
|
return completeJson(incompleteJson, stack);
|
|
}
|