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

Function stringifyJson

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

Source from the content-addressed store, hash-verified

1085 * @since 4.0.0
1086 */
1087export function stringifyJson(options?: StringifyJsonOptions): Getter<string, unknown> {
1088 return onSome((input, parseOptions) =>
1089 Effect.try({
1090 try: () => {
1091 const output = JSON.stringify(input, options?.replacer as any, options?.space)
1092 if (output === undefined) {
1093 throw new TypeError("Value cannot be represented as JSON")
1094 }
1095 return Option.some(output)
1096 },
1097 catch: () =>
1098 new SchemaIssue.InvalidValue(
1099 { expected: "a JSON-serializable value" },
1100 input,
1101 parseOptions
1102 )
1103 })
1104 )
1105}
1106
1107/**
1108 * Parses a string into a record of key-value pairs.

Callers

nothing calls this directly

Calls 2

someMethod · 0.80
onSomeFunction · 0.70

Tested by

no test coverage detected