UNPKG

confbox

Version:

Compact and high quality YAML, TOML, JSONC and JSON5 parsers

27 lines (25 loc) 898 B
/** * * Converts a [JSONC](https://github.com/microsoft/node-jsonc-parser) string into an object. * * @NOTE On invalid input, the parser tries to be as fault tolerant as possible, but still return a result. * Therefore, always check the errors list to find out if the input was valid. * * @template T The type of the return value. * @param text The string to parse as JSONC. * @param options Parsing options. * @returns The JavaScript value converted from the JSONC string. */ declare function parseJSONC<T = unknown>(text: string, options?: JSONCParseOptions): T; interface JSONCParseOptions { disallowComments?: boolean; allowTrailingComma?: boolean; allowEmptyContent?: boolean; errors?: JSONCParseError[]; } interface JSONCParseError { error: number; offset: number; length: number; } export { type JSONCParseError, type JSONCParseOptions, parseJSONC };