Function parseJson

  • Parses JSON. The result is passed to opt, any error results in None.

    Parameters

    • x: string

    Returns Opt<unknown>

    Example

    parseJson('{"a": 1}') // Some({a: 1})
    parseJson('Ryoka') // None
    parseJson('null') // None - valid JSON (according to the new standard), but opt(null) is None

    Typical use is to call Opt.narrow afterwards to validate parsed data and get proper type.

Generated using TypeDoc