parseJson
functionfunction parseJson<T>(content: string, filePath?: string): Promise<T>;Parses a JSON string with progressive fallbacks:
- Standard JSON.parse
- jsonc-parser (handles comments and trailing commas)
- json5 (handles extended JSON5 syntax)
If all parsers fail, throws a JsonParseError with a formatted
code frame showing the error location.
PARAMETERS
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| content | string | The JSON string to parse |
| filePath? | string | Optional file path for error messages |
RETURNS
Promise<T>TYPE PARAMETERS
T=unknown