Releases: Tarmil/FSharp.SystemTextJson
Version 1.4.36
Version 1.4
- #177: Support enum-like unions (ie unions where no cases have fields) as key for maps and dictionaries.
- #180: In
WithOverrides, allow usingtypedefofto override generic types. - #181: Add
WithOverrideMembersoption to add JsonNameAttributes to given record fields or union cases. - #192: Update dependency on System.Text.Json to 6.0.10.
- #195: Fix
JsonNameAttribute'sPropertyTargetsso that it can be applied to cases with arguments when compiling with F# 9. - #198: Improve performance of type comparisons.
- #201: Reduce memory allocations when serializing or deserializing tuples and struct tuples with 2, 3 or 4 items.
Version 1.3
- #151: Add optional argument
deserializeNullAsNone: boolto option.WithSkippableOptionFields(SkippableOptionFields). When true, skippable option fields can be deserialized asNonenot only from a missing field, but also fromnull.
Patch 1.2.42
Fix #172: NullReferenceException when serializing a null record.
Version 1.2
-
#154: Add
SkippableOptionFieldsenum to further customize the skipping of fields of typeoptionandvoptionwithWithSkippableOptionFields.SkippableOptionFields.FromJsonSerializerOptionsis the default and equivalent toWithSkippableOptionFields(false): fields of typeoptionandvoptionare skipped if used withJsonIgnoreCondition.WhenWritingNull.SkippableOptionFields.Alwaysis equivalent toWithSkippableOptionFields(true): fields of typeoptionandvoptionare always skipped.SkippableOptionFields.Never: fields of typeoptionandvoptionare never skipped.
-
#159: Throw an exception when trying to deserialize
nullinto a record or union in any context, rather than only when they are in fields of records and unions. -
#160: Fix
WithSkippableOptionFields(false)not working forvoption. -
#161: Allow using single-case unions as keys in all dictionary types.
NOTE: This requires System.Text.Json 8.0. -
#162: Add option
.WithMapFormat(MapFormat)to customize the format of F# maps.MapFormat.Objectalways serializes maps as objects. The key type must be supported as key for dictionaries.
NOTE: This requires System.Text.Json 8.0.MapFormat.ArrayOfPairsalways serializes maps as JSON arrays whose items are[key,value]pairs.MapFormat.ObjectOrArrayOfPairsis the default: maps whose keys are string or single-case unions wrapping string are serialized as JSON objects, and other maps are serialized as JSON arrays whose items are[key,value]pairs.
-
#163: Add
StructuralComparisonto the typeSkippable<_>. -
#164: When deserializing a record with
JsonIgnoreCondition.WhenWritingNull, when a non-nullable field is missing, throw a properJsonExceptionrather than aNullReferenceException.
Version 1.1
-
#141: Add fluent options builder.
JsonFSharpOptionshas the following new methods:- static methods that create options with default settings:
.Default(),.NewtonsoftLike(),.FSharpLuLike()and.ThothLike(). - instance methods
.WithOptionAbc(?bool)for each flagJsonUnionEncoding.Abc, that sets or unsets this option and returns a newJsonFSharpOptions. - instance methods
.WithAbc(value)for each optional argumentabcof its constructor, that sets this option and returns a newJsonFSharpOptions. - an instance method
.ToJsonSerializerOptions()that returns a newJsonSerializerOptionswith the correspondingJsonFSharpConverterconfigured. - an instance method
.AddToJsonSerializerOptions(options)that takes an existingJsonSerializerOptions, configures the correspondingJsonFSharpConverterand returnsunit.
The above is now the recommended way of configuring the library, and future options may be only made available using fluent methods and not using constructor arguments.
- static methods that create options with default settings:
-
#146: Add option
.WithSkippableOptionFields(?bool)that makes fields of typeoptionandvoptionbehave likeSkippable:None/ValueNoneis represented by a missing field instead of anullvalue.This is equivalent to the pre-1.0 default behavior, and is now recommended if this behavior is desired instead of
IgnoreNullValues = trueorDefaultIgnoreCondition = WhenWritingNull.
Version 1.0.7
- Fix regression #137: exception on serialization and deserialization of empty anonymous records.
Version 1.0.6
Fix regression #133: failure on non-public records.
Version 1.0
-
#89: Add
JsonNameAttributeas a more powerful substitute for the standardJsonPropertyNameAttribute.- When used on a discriminated union case,
JsonNameAttributecan take a value of typeintorboolinstead ofstring. JsonNameAttributecan take multiple values. When deserializing, all these values are treated as equivalent. When serializing, the first one is used.JsonNameAttributehas a settable propertyField: string. It is used to set the JSON name of a union case field with the given name.
- When used on a discriminated union case,
-
#92: Serialization of record properties (in addition to fields).
- Add option
includeRecordProperties: boolto enable serializing record properties. - Also serialize record properties with
JsonIncludeAttributeeven whenincludeRecordPropertiesis false.
- Add option
-
Add support for the standard
DefaultIgnoreCondition.WhenWritingNullas a synonym forIgnoreNullValues = truethat allowsNoneandValueNoneto be omitted instead ofnull. -
#123: BREAKING CHANGE: Missing fields of type
optionorvoptionnow throw an error by default instead of being deserialized toNone/ValueNone. To support missing fields, either enable the optionIgnoreNullValues = trueorDefaultIgnoreCondition = WhenWritingNull, or use the typeSkippableinstead ofoptionorvoption. -
#126: Add option
types: JsonFSharpTypesthat specifies which types the F# converter should handle. Unlisted types will be handled by the defaultSystem.Text.Json. By default, all supported types are handled.