Skip to content

parseJsonConfig

parseJsonConfig<T>(raw, schema): JsonConfigResult<T>

Defined in: packages/simply-core/src/config/loadJsonConfig.ts:47

Parse a JSON string and validate it against a schema.

T

string

The raw JSON text to parse.

ConfigSchema<T>

The schema to validate the parsed value against.

JsonConfigResult<T>

The validated value, or the validator’s error message.

If raw isn’t valid JSON. Callers that want to report malformed JSON differently from schema violations should catch this; the two failures are otherwise indistinguishable to whoever wrote the file.