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

Function json

packages/effect/src/http/HttpBody.ts:360–364  ·  view source on GitHub ↗
(body: unknown, contentType?: string)

Source from the content-addressed store, hash-verified

358 * @since 4.0.0
359 */
360export const json = (body: unknown, contentType?: string): Effect.Effect<Uint8Array, HttpBodyError> =>
361 Effect.try({
362 try: () => text(JSON.stringify(body), contentType ?? "application/json"),
363 catch: (cause) => new HttpBodyError({ reason: { _tag: "JsonError" }, cause })
364 })
365
366/**
367 * Creates a JSON body constructor that first encodes values with the schema's JSON codec.

Callers 2

jsonSchemaFunction · 0.70
Schema.tsFile · 0.50

Calls 1

textFunction · 0.70

Tested by

no test coverage detected