Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseJSON(input: string): any {
const errors: ParseError[] = []
const o = parse(input, errors, { allowTrailingComma: true, disallowComments: false })
if (errors.length > 0) {
throw createAggregateError(
errors.map(v => ({
...v,
code: ParseErrorCode[v.error],
message: `parse error (code: ${v.error}, offset: ${v.offset}, length: ${v.length})`,
}))
)
}
return o
}