Header menu logo JDeck

Decode Module

Functions and values

Function or value Description

array decoder el

Full Usage: array decoder el

Parameters:
Returns: Result<'TResult array, DecodeError>
Modifiers: inline
Type parameters: 'TResult

Decodes a JSON array element into a value of type .

If a failure is encountered in the decoding process, the decoding stops there, and the error is returned, the rest of the array is not decoded.

decoder : IndexedDecoder<'TResult>

el : JsonElement

Returns: Result<'TResult array, DecodeError>

auto el

Full Usage: auto el

Parameters:
Returns: Result<'TResult, DecodeError>
Modifiers: inline
Type parameters: 'TResult

Uses the standard System.Text.Json deserialization means to deserialize a JSON element into a value of type .

For the most part it is recommended that you use this function unless you have a "F# types based" object like discriminated unions, Which are not supported by the standard deserialization means.

el : JsonElement

Returns: Result<'TResult, DecodeError>

autoJsonOptions options el

Full Usage: autoJsonOptions options el

Parameters:
Returns: Result<'TResult, DecodeError>
Modifiers: inline
Type parameters: 'TResult

Uses the standard System.Text.Json deserialization means to deserialize a JSON element into a value of type . You can pass JsonSerializerOptions to customize the deserialization process and even include your decoders in the process.

For the most part it is recommended that you use this function unless you have a "F# types based" object like discriminated unions, Which are not supported by the standard deserialization means.

options : JsonSerializerOptions

el : JsonElement

Returns: Result<'TResult, DecodeError>

collectOneOf decoders element

Full Usage: collectOneOf decoders element

Parameters:
Returns: Result<'TResult, DecodeError list>

Takes a list of possible decoders and tries to decode the JSON element with each one of them.

This is useful to decode JSON elements into discriminated unions

decoders : Decoder<'TResult> seq

element : JsonElement

Returns: Result<'TResult, DecodeError list>

decodeAt decoder index el

Full Usage: decodeAt decoder index el

Parameters:
Returns: Result<'TResult, DecodeError>
Modifiers: inline
Type parameters: 'TResult

Attempts to decode a JSON element that is living inside an array at the given index.

decoder : Decoder<'TResult>

index : int

el : JsonElement

Returns: Result<'TResult, DecodeError>

decodeAtKey decoder key el

Full Usage: decodeAtKey decoder key el

Parameters:
Returns: Result<'TResult, DecodeError>
Modifiers: inline
Type parameters: 'TResult

Attempts to decode a JSON element that is living inside an array at the given key.

decoder : Decoder<'TResult>

key : string

el : JsonElement

Returns: Result<'TResult, DecodeError>

dict decoder el

Full Usage: dict decoder el

Parameters:
Returns: Result<Dictionary<string, 'TValue>, DecodeError>
Modifiers: inline
Type parameters: 'TValue

Decodes a JSON object into a BCL Dictionary where the keys are strings and the value is of type

decoder : IndexedMapDecoder<'TValue>

el : JsonElement

Returns: Result<Dictionary<string, 'TValue>, DecodeError>

dictCol decoder el

Full Usage: dictCol decoder el

Parameters:
Returns: Result<Dictionary<string, 'TValue>, DecodeError seq>
Modifiers: inline
Type parameters: 'TValue

Decodes a JSON object into a BCL Dictionary where the keys are strings and the value is of type

decoder : IndexedMapCollectErrorsDecoder<'TValue>

el : JsonElement

Returns: Result<Dictionary<string, 'TValue>, DecodeError seq>

list decoder el

Full Usage: list decoder el

Parameters:
Returns: Result<'TResult list, DecodeError>
Modifiers: inline
Type parameters: 'TResult

Decodes a JSON array element into a value of type .

If a failure is encountered in the decoding process, the decoding stops there and the error is returned, the rest of the array is not decoded.

decoder : IndexedDecoder<'TResult>

el : JsonElement

Returns: Result<'TResult list, DecodeError>

map decoder el

Full Usage: map decoder el

Parameters:
Returns: Result<Map<string, 'TValue>, DecodeError>
Modifiers: inline
Type parameters: 'TValue

Decodes a JSON object into an FSharpMap where the keys are strings and the value is of type

decoder : IndexedMapDecoder<'TValue>

el : JsonElement

Returns: Result<Map<string, 'TValue>, DecodeError>

mapCol decoder el

Full Usage: mapCol decoder el

Parameters:
Returns: Result<Map<string, 'TValue>, DecodeError seq>
Modifiers: inline
Type parameters: 'TValue

Decodes a JSON object into an FSharpMap where the keys are strings and the value is of type

decoder : IndexedMapCollectErrorsDecoder<'TValue>

el : JsonElement

Returns: Result<Map<string, 'TValue>, DecodeError seq>

oneOf decoders

Full Usage: oneOf decoders

Parameters:
    decoders : Decoder<'TResult> seq -

Returns: Decoder<'TResult>

Takes a list of possible decoders and tries to decode the JSON element with each one of them.

This is useful to decode JSON elements into discriminated unions

decoders : Decoder<'TResult> seq

Returns: Decoder<'TResult>

sequence decoder el

Full Usage: sequence decoder el

Parameters:
Returns: Result<'TResult seq, DecodeError>
Modifiers: inline
Type parameters: 'TResult

Decodes a JSON array element into a value of type .

If a failure is encountered in the decoding process, the decoding stops there and the error is returned, the rest of the array is not decoded.

decoder : IndexedDecoder<'TResult>

el : JsonElement

Returns: Result<'TResult seq, DecodeError>

sequenceCol decoder el

Full Usage: sequenceCol decoder el

Parameters:
Returns: Result<'a seq, DecodeError list>
Modifiers: inline
Type parameters: 'a

Decodes a JSON array element into the value of type .

If a failure is encountered in the decoding process, the error is collected and the decoding continues however, the result will be an error containing a list of all the errors that occurred during the decoding process.

decoder : IndexedCollectErrorsDecoder<'a>

el : JsonElement

Returns: Result<'a seq, DecodeError list>

tryDecodeAt decoder index el

Full Usage: tryDecodeAt decoder index el

Parameters:
Returns: Result<'TResult option, DecodeError>
Modifiers: inline
Type parameters: 'TResult

Attempts to decode a JSON element that is living inside an array at the given index.

If the element is not found, this will not fail but return an option type.

decoder : Decoder<'TResult>

index : int

el : JsonElement

Returns: Result<'TResult option, DecodeError>

tryDecodeAtKey decoder key el

Full Usage: tryDecodeAtKey decoder key el

Parameters:
Returns: Result<'TResult option, DecodeError>
Modifiers: inline
Type parameters: 'TResult

Attempts to decode a JSON element that is living inside an array at the given key.

If the element is not found, this will not fail but return an option type.

decoder : Decoder<'TResult>

key : string

el : JsonElement

Returns: Result<'TResult option, DecodeError>

Type something to start searching.