Header menu logo CodecMapper

Json Module

JSON codec compilation and runtime helpers. Compile a schema once, then reuse the resulting codec for repeated JSON serialization and deserialization.

Types

Type Description

Codec<'T>

A compiled JSON codec for a specific schema.

CompiledCodec

Decoder<'T>

Decoder shape used by the compiled JSON runtime.

JsonSource

The byte-level input state for JSON decoding.

JsonWriter

The byte-level output abstraction used by JSON encoders.

Functions and values

Function or value Description

buildAndCompile builder

Full Usage: buildAndCompile builder

Parameters:
Returns: Codec<'T>
Modifiers: inline
Type parameters: 'T

Inline schema pipelines read more clearly when the final `build` and JSON compile step collapse into one terminal pipeline stage.

builder : Builder<'T, 'T>
Returns: Codec<'T>

codec schema

Full Usage: codec schema

Parameters:
Returns: Codec<'T>

`codec` remains as the shorter schema-to-codec alias for callers that prefer the direct `compile schema` shape without the longer name.

schema : Schema<'T>
Returns: Codec<'T>

compile schema

Full Usage: compile schema

Parameters:
Returns: Codec<'T>

Compiles a schema into a reusable JSON codec.

schema : Schema<'T>
Returns: Codec<'T>

compileUntyped schema

Full Usage: compileUntyped schema

Parameters:
Returns: CompiledCodec
schema : ISchema
Returns: CompiledCodec

deserialize codec json

Full Usage: deserialize codec json

Parameters:
    codec : Codec<'T>
    json : string

Returns: 'T

Deserializes a JSON payload using a previously compiled codec. The entire payload must be consumed. Trailing content is treated as an error rather than ignored.

codec : Codec<'T>
json : string
Returns: 'T

deserializeBytes codec bytes

Full Usage: deserializeBytes codec bytes

Parameters:
    codec : Codec<'T>
    bytes : byte[]

Returns: 'T

Deserializes a UTF-8 byte payload using a previously compiled codec.

codec : Codec<'T>
bytes : byte[]
Returns: 'T

serialize codec value

Full Usage: serialize codec value

Parameters:
    codec : Codec<'T>
    value : 'T

Returns: string

Serializes a value to JSON using a previously compiled codec.

codec : Codec<'T>
value : 'T
Returns: string

Type something to start searching.