| 1025 | export function parseJson<E extends string>(): Getter<Schema.MutableJson, E> |
| 1026 | export function parseJson<E extends string>(options: ParseJsonOptions): Getter<unknown, E> |
| 1027 | export function parseJson<E extends string>(options?: ParseJsonOptions | undefined): Getter<unknown, E> { |
| 1028 | return onSome((input, parseOptions) => |
| 1029 | Effect.try({ |
| 1030 | try: () => Option.some(JSON.parse(input, options?.reviver)), |
| 1031 | catch: () => |
| 1032 | new SchemaIssue.InvalidValue( |
| 1033 | { expected: "a valid JSON string" }, |
| 1034 | input, |
| 1035 | parseOptions |
| 1036 | ) |
| 1037 | }) |
| 1038 | ) |
| 1039 | } |
| 1040 | |
| 1041 | /** |
| 1042 | * Replacer function or property allowlist accepted by `JSON.stringify`. |