Hyperlinkv0.8.0-beta.28

SchemaRepresentation

SchemaRepresentation.DocumentFromJsonconsteffect/SchemaRepresentation.ts:1684
Schema.Codec<Document, Schema.Json, never, never>

Schema that decodes a Document from JSON and encodes it back.

When to use

Use when you need a JSON codec for schema representation documents with Schema.decodeUnknownSync or Schema.encodeSync.

Example (Round-tripping a Document through JSON)

import { Schema, SchemaRepresentation } from "effect"

const doc = SchemaRepresentation.fromAST(Schema.String.ast)
const json = Schema.encodeSync(SchemaRepresentation.DocumentFromJson)(doc)
const back = Schema.decodeUnknownSync(SchemaRepresentation.DocumentFromJson)(json)
export const DocumentFromJson: Schema.Codec<Document, Schema.Json> = Schema.toCodecJson($Document)