MCPcopy Create free account
hub / github.com/Effect-TS/effect / stringifyJson

Function stringifyJson

packages/effect/src/SchemaGetter.ts:1338–1356  ·  view source on GitHub ↗
(options?: StringifyJsonOptions)

Source from the content-addressed store, hash-verified

1336 * @since 4.0.0
1337 */
1338export 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.

Callers

nothing calls this directly

Calls 1

transformEffectFunction · 0.70

Tested by

no test coverage detected