Bot releases are hidden (Show)
Published by Tarmil over 4 years ago
JsonUnionEncoding.UnwrapRecordCases
, which implies JsonUnionEncoding.NamedFields
and encodes union cases containing a single record field as if the record's fields were the union's fields instead. For example:
type U =
| U of r: {| x: int; y: bool |}
U {| x = 1; y = true |}
// Serialized as: {"Case":"U","Fields":{"x":1,"y":true}}
// Instead of: {"Case":"U","Fields":{"r":{"x":1,"y":true}}}
This option is compatible with all union formats (AdjacentTag
, ExternalTag
, InternalTag
and Untagged
).unit
as field of an F# type. Thanks @NickDarvey!Published by Tarmil over 4 years ago
#54: Do throw an exception when a mandatory field is missing and an optional field was omitted. Thanks @fuchen!
#57: Do throw an exception when a parsed value is null inside an array, a set or a tuple, unless allowNullFields
is true. Thanks @drhumlen!
Published by Tarmil over 4 years ago
Skippable<'T>
to represent values that can be omitted from the serialization of a record or a union with NamedFields
. This is particularly useful with Skippable<'T option>
(or voption
) to represent a field that can be omitted, null, or have a proper value.
type R = { x: Skippable<int option> }
{ x = Skip } // Serialized as: {}
{ x = Include None } // Serialized as: {"x":null}
{ x = Include (Some 42) } // Serialized as: {"x":42}
Also add a Skippable
module with standard functions: map
, filter
, etc. Implementation largely based on @cmeeren's JsonSkippable which provides the same functionality for Newtonsoft.Json.K
is a single-case union wrapping a string, serialize Map<K, V>
into a JSON object, like Map<string, V>
.JsonUnionEncoding
(AdjacentTag
, InternalTag
, ExternalTag
or Untagged
) with Default
to use the default extra options (UnwrapOption ||| UnwrapSingleCaseUnions
).Published by Tarmil over 4 years ago
Published by Tarmil over 4 years ago
#30: Unwrap 'T voption
with JsonUnionEncoding.UnwrapOption
. Thanks @johlrich!
#32: Add JsonUnionEncoding.UnwrapSingleFieldCases
, which encodes the field of single-field cases as x
instead of [x]
. Include it in JsonUnionEncoding.FSharpLuLike
.
#33: Fix "read too much or not enough" when parsing a list of unions with JsonUnionEncoding.UnwrapFieldlessTags
.
#36: BREAKING CHANGE: During deserialization, throw an exception when a field of a record or union has value null
, unless the type of this field is option
, voption
, or a union with UseNullAsTrueValue
. Thanks @drhumlen!
New option allowNullFields
disables this behavior.
#38: Add more consistent names for options:
BareFieldlessTags
becomes UnwrapFieldlessTags
;SuccintOption
becomes UnwrapOption
;EraseSingleCaseUnions
becomes UnwrapSingleCaseUnions
.The previous names are marked Obsolete
.
Published by Tarmil almost 5 years ago
PropertyNamingPolicy
on record and union fields.DictionaryKeyPolicy
for Map<string, 'T>
.unionTagNamingPolicy
option to JsonFSharpConverter
and JsonFSharpConverterAttribute
to customize the naming policy for union tag names.JsonUnionEncoding.EraseSingleCaseUnions
, which encodes single-case single-field unions the same as the value in the field.PropertyNameCaseInsensitive
on record and union fields.unionTagCaseInsensitive
option to JsonFSharpConverter
and JsonFSharpConverterAttribute
to customize the case sensitivity for union tag names.Published by Tarmil almost 5 years ago
IgnoreNullValues
on record and union fields.JsonPropertyNameAttribute
on union cases to set the tag name to use for this case.JsonUnionEncoding.SuccintOption
, which encodes Some x
the same as x
.unionTagName
and unionFieldsName
option to customize the "Case"
and "Fields"
tags for unions.JsonUnionEncoding.FSharpLuLike
, which is equivalent to ExternalTag ||| BareFieldlessTags ||| SuccintOption
.Published by Tarmil about 5 years ago
Initial release.
Published by Tarmil about 5 years ago
JsonPropertyNameAttribute
.JsonIgnoreAttribute
.Published by Tarmil about 5 years ago
Published by Tarmil about 5 years ago
JsonFSharpConverter
and JsonFSharpConverterAttribute
now take JsonUnionEncoding
as optional argument.JsonUnionEncoding
as detailed in the documentation.Published by Tarmil about 5 years ago
'T list
encoded as JSON array.Set<'T>
encoded as JSON array.Map<string, 'T>
encoded as JSON object with map keys as field names.Map<'K, 'V>
when 'K
is not string
encoded as JSON array whose elements are [key,value]
JSON arrays.