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

Function json

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

Source from the content-addressed store, hash-verified

302 * @since 4.0.0
303 */
304export const json = (body: unknown, contentType?: string): Effect.Effect<Uint8Array, HttpBodyError> =>
305 Effect.try({
306 try: () => text(JSON.stringify(body), contentType ?? "application/json"),
307 catch: (cause) => new HttpBodyError({ reason: { _tag: "JsonError" }, cause })
308 })
309
310/**
311 * Creates a JSON body constructor that first encodes values with the schema's JSON codec.

Callers 1

jsonSchemaFunction · 0.70

Calls 1

textFunction · 0.70

Tested by

no test coverage detected