(options?: StringifyJsonOptions)
| 1336 | * @since 4.0.0 |
| 1337 | */ |
| 1338 | export function stringifyJson(options?: StringifyJsonOptions): Getter<string, unknown> { |
| 1339 | return transformEffect((input, parseOptions) => |
| 1340 | Effect.try({ |
| 1341 | try: () => { |
| 1342 | const output = JSON.stringify(input, options?.replacer as any, options?.space) |
| 1343 | if (output === undefined) { |
| 1344 | throw new TypeError("Value cannot be represented as JSON") |
| 1345 | } |
| 1346 | return output |
| 1347 | }, |
| 1348 | catch: () => |
| 1349 | new SchemaIssue.InvalidValue( |
| 1350 | { expected: "a JSON-serializable value" }, |
| 1351 | input, |
| 1352 | parseOptions |
| 1353 | ) |
| 1354 | }) |
| 1355 | ) |
| 1356 | } |
| 1357 | |
| 1358 | /** |
| 1359 | * Parses a string into a record of key-value pairs. |
nothing calls this directly
no test coverage detected