Function
json
(body: unknown, contentType?: string)
Source from the content-addressed store, hash-verified
| 302 | * @since 4.0.0 |
| 303 | */ |
| 304 | export 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. |
Tested by
no test coverage detected