Decode
module Decode| Assembly | Ranvier.Wire |
| Attributes | [<RequireQualifiedAccess>] |
Declared inside
Advanced | |
Enum | |
Getters | |
Helpers | |
IGetters | |
IOptionalGetter | |
IRequiredGetter |
Functions and values
andMap<'a, 'b>: Decoder<'a> -> Decoder<('a -> 'b)> -> Decoder<'b>
andMap<'a, 'b>: Decoder<'a> -> Decoder<('a -> 'b)> -> Decoder<'b>Apply one decoded value to a decoded function, for building a value field by field.
type Point =
{
X : float
Y : float
}
module Point =
let create x y = { X = x; Y = y }
let decode =
Decode.succeed create
|> Decode.andMap (Decode.field "x" Decode.float)
|> Decode.andMap (Decode.field "y" Decode.float)
bigint: Decoder<bigint>
bigint: Decoder<bigint>Decode a JSON string or number into a bigint.
bool: Decoder<bool>
bool: Decoder<bool>Decode a JSON boolean.
byte: Decoder<byte>
byte: Decoder<byte>Alias to Decode.uint8
char: Decoder<char>
char: Decoder<char>Decode a JSON string into an F# char.
Decode.fromString Decode.char "a" == Ok 'a'
Decode.fromString Decode.char "ab" == Error ...
Decode.fromString Decode.char "true" == Error ...
Decode.fromString Decode.char "42" == Error ...
codec<'t> (c: Codec<'t>) : Decoder<'t>
codec<'t> (c: Codec<'t>) : Decoder<'t>The decoder half of a codec.
datetimeLocal: Decoder<DateTime>
datetimeLocal: Decoder<DateTime>Decode a System.DateTime with DateTime.TryParse; uses default System.DateTimeStyles.
datetimeOffset: Decoder<DateTimeOffset>
datetimeOffset: Decoder<DateTimeOffset>Decode a JSON string into a DateTimeOffset.
datetimeUtc: Decoder<DateTime>
datetimeUtc: Decoder<DateTime>Decode a System.DateTime value using Sytem.DateTime.TryParse, then convert it to UTC.
decimal: Decoder<decimal>
decimal: Decoder<decimal>Decode a JSON string or number into a decimal.
errorToString<'JsonValue> (helpers: IDecoderHelpers<'JsonValue>) (path: string, error: ErrorReason<'JsonValue>) : string
errorToString<'JsonValue> (helpers: IDecoderHelpers<'JsonValue>) (path: string, error: ErrorReason<'JsonValue>) : stringFormat a decoding failure as the message the entry points return.
fail<'a> (msg: string) : Decoder<'a>
fail<'a> (msg: string) : Decoder<'a>Always fail with the given message.
fix<'a> (make: Decoder<'a> -> Decoder<'a>) : Decoder<'a>
fix<'a> (make: Decoder<'a> -> Decoder<'a>) : Decoder<'a>Allow to build a decoder that can call itself
type Tree =
| Empty
| Branch of Tree * int * Tree
module Tree =
let decode =
Decode.fix
(fun self ->
Decode.oneOf
[
Decode.unit
|> Decode.map (fun () -> Tree.Empty)
Decode.tuple3 self Decode.int self
|> Decode.map Tree.Branch
])
float: Decoder<float>
float: Decoder<float>Decode a JSON number into a float.
float32: Decoder<float32>
float32: Decoder<float32>Decode a JSON number into a float32.
guid: Decoder<Guid>
guid: Decoder<Guid>Decode a JSON string into an F# Guid.
Decode.fromString Decode.guid "58bd4436-7583-40e2-bd3c-aa3c5d0b4286" == Ok (System.Guid "58bd4436-7583-40e2-bd3c-aa3c5d0b4286")
Decode.fromString Decode.guid "58bd4436-aa3c5d0b4286" == Error ...
int: Decoder<int>
int: Decoder<int>Decode a JSON number or string into an int.
int16: Decoder<int16>
int16: Decoder<int16>Decode a JSON number or string into an int16.
int64: Decoder<int64>
int64: Decoder<int64>Decode a JSON string or number into an int64.
keys: Decoder<string list>
keys: Decoder<string list>The property names of an object.
map8<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'Output> (ctor: 'a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g -> 'h -> 'Output) (d1: Decoder<'a>) (d2: Decoder<'b>) (d3: Decoder<'c>) (d4: Decoder<'d>) (d5: Decoder<'e>) (d6: Decoder<'f>) (d7: Decoder<'g>) (d8: Decoder<'h>) : Decoder<'Output>
map8<'a, 'b, 'c, 'd, 'e, 'f, 'g, 'h, 'Output> (ctor: 'a -> 'b -> 'c -> 'd -> 'e -> 'f -> 'g -> 'h -> 'Output) (d1: Decoder<'a>) (d2: Decoder<'b>) (d3: Decoder<'c>) (d4: Decoder<'d>) (d5: Decoder<'e>) (d6: Decoder<'f>) (d7: Decoder<'g>) (d8: Decoder<'h>) : Decoder<'Output>Decode with eight decoders and combine their results.
nil<'a> (output: 'a) : Decoder<'a>
nil<'a> (output: 'a) : Decoder<'a>Decode null into the given value, and fail on anything else.
sbyte: Decoder<sbyte>
sbyte: Decoder<sbyte>Decode a JSON number or string into an sbyte.
string: Decoder<string>
string: Decoder<string>Decode a JSON string into an F# string.
Decode.fromString Decode.string "Hello" == Ok "Hello"
Decode.fromString Decode.string "42" == Error ...
Decode.fromString Decode.string "true" == Error ...
Decode.fromString Decode.string "{ \"foo\": 42 }" == Error ...
succeed<'a> (output: 'a) : Decoder<'a>
succeed<'a> (output: 'a) : Decoder<'a>Always succeed with the given value, whatever the JSON.
timespan: Decoder<TimeSpan>
timespan: Decoder<TimeSpan>Decode a JSON string into a TimeSpan.
tuple7<'T1, 'T2, 'T3, 'T4, 'T5, 'T6, 'T7> (decoder1: Decoder<'T1>) (decoder2: Decoder<'T2>) (decoder3: Decoder<'T3>) (decoder4: Decoder<'T4>) (decoder5: Decoder<'T5>) (decoder6: Decoder<'T6>) (decoder7: Decoder<'T7>) : Decoder<'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7>
tuple7<'T1, 'T2, 'T3, 'T4, 'T5, 'T6, 'T7> (decoder1: Decoder<'T1>) (decoder2: Decoder<'T2>) (decoder3: Decoder<'T3>) (decoder4: Decoder<'T4>) (decoder5: Decoder<'T5>) (decoder6: Decoder<'T6>) (decoder7: Decoder<'T7>) : Decoder<'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7>Decode a JSON array of 7 elements into a tuple.
tuple8<'T1, 'T2, 'T3, 'T4, 'T5, 'T6, 'T7, 'T8> (decoder1: Decoder<'T1>) (decoder2: Decoder<'T2>) (decoder3: Decoder<'T3>) (decoder4: Decoder<'T4>) (decoder5: Decoder<'T5>) (decoder6: Decoder<'T6>) (decoder7: Decoder<'T7>) (decoder8: Decoder<'T8>) : Decoder<'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8>
tuple8<'T1, 'T2, 'T3, 'T4, 'T5, 'T6, 'T7, 'T8> (decoder1: Decoder<'T1>) (decoder2: Decoder<'T2>) (decoder3: Decoder<'T3>) (decoder4: Decoder<'T4>) (decoder5: Decoder<'T5>) (decoder6: Decoder<'T6>) (decoder7: Decoder<'T7>) (decoder8: Decoder<'T8>) : Decoder<'T1 * 'T2 * 'T3 * 'T4 * 'T5 * 'T6 * 'T7 * 'T8>Decode a JSON array of 8 elements into a tuple.
uint16: Decoder<uint16>
uint16: Decoder<uint16>Decode a JSON number or string into a uint16.
uint32: Decoder<uint32>
uint32: Decoder<uint32>Decode a JSON number or string into a uint32.
uint64: Decoder<uint64>
uint64: Decoder<uint64>Decode a JSON string or number into a uint64.
unit: Decoder<unit>
unit: Decoder<unit>Decode a JSON null value into an F# unit.
Decode.fromString Decode.unit "null" == Ok ()
Decode.fromString Decode.unit "42" == Error ...
uri: Decoder<Uri>
uri: Decoder<Uri>Decode a JSON string into a System.Uri.
The string is parsed with UriKind.RelativeOrAbsolute, so both absolute (e.g. https://example.com) and relative (e.g. /path?query=1) URIs are accepted.
Decode.fromString Decode.uri "\"https://example.com\"" == Ok (System.Uri "https://example.com")