FSharp.SystemTextJson icon indicating copy to clipboard operation
FSharp.SystemTextJson copied to clipboard

Custom serializer/`JsonConverter` for a record

Open rynoV opened this issue 1 year ago • 4 comments

Thanks for making this!

I didn't see this in the docs so I thought I'd mention it here: when registering a custom JsonConverter for a type in JsonFSharpTypes (e.g. records), it seems necessary to add it to the JsonSerializerOptions.Converters list before adding the json fsharp serializer options with AddToJsonSerializerOptions. Otherwise the fsharp record converter takes precedence.

Adding the JsonConverter directly to the record doesn't seem to take precedence. And it doesn't seem like using ToJsonSerializerOptions would work either.

rynoV avatar Apr 25 '24 21:04 rynoV

Thanks, this has been very helpful to me.

nkosi23 avatar Jun 28 '24 19:06 nkosi23