Package: effect
Module: SchemaTransformation
Decodes a JSON string with JSON.parse and encodes a value with
JSON.stringify.
When to use
Use when you need a schema transformation to decode JSON stored or transmitted as a string, usually before composing with another schema that validates the parsed structure.
Details
Decode fails with InvalidValue for invalid JSON, and encode can fail with
InvalidValue when JSON.stringify cannot serialize the value.
Example (Parsing JSON)
import { Schema, SchemaTransformation } from "effect"
const schema = Schema.String.pipe(
Schema.decodeTo(Schema.Unknown, SchemaTransformation.fromJsonString)
)
See
uint8ArrayFromBase64StringfromFormDataSignature
declare const fromJsonString: Transformation<unknown, string, never, never>
Since v4.0.0