Safely parse JSON with helpful error messages.
The JSON string to parse.
Optional
Optional context about what's being parsed (e.g., file path, "API response").
The parsed JSON object.
AbortError if JSON is malformed.
// Parse with contextconst data = parseJSON(jsonString, '/path/to/config.json') Copy
// Parse with contextconst data = parseJSON(jsonString, '/path/to/config.json')
// Parse without contextconst data = parseJSON(jsonString) Copy
// Parse without contextconst data = parseJSON(jsonString)
Safely parse JSON with helpful error messages.