xperiandri / FSharp.SystemTextJson

System.Text.Json extensions for F# types

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Build status Nuget

This library provides support for F# types to System.Text.Json.

It adds support for the following types:

  • F# records (including struct records and anonymous records);

  • F# discriminated unions (including struct unions), with a variety of representations;

  • F# collections: list<'T>, Map<'T>, Set<'T>.

It provides a number of customization options, allowing a wide range of JSON serialization formats.



  • Does FSharp.SystemTextJson support alternative formats for unions?


  • Does FSharp.SystemTextJson support representing 'T option as either just 'T or null (or an absent field)?

Yes! Starting with v0.6, this is the default behavior. To supersede it, use an explicit JsonUnionEncoding that does not include UnwrapOption.

  • Does FSharp.SystemTextJson support JsonPropertyNameAttribute and JsonIgnoreAttribute on record fields?


  • Does FSharp.SystemTextJson support options such as PropertyNamingPolicy and IgnoreNullValues?


  • Can I customize the format for a specific type?


  • Does FSharp.SystemTextJson allocate memory?

As little as possible, but unfortunately the FSharp.Reflection API requires some allocations. In particular, an array is allocated for as many items as the record fields or union arguments, and structs are boxed. There is work in progress to improve this.

  • Are there any benchmarks, e.g. against Newtonsoft.Json?



System.Text.Json extensions for F# types

License:MIT License


Language:F# 99.9%Language:Shell 0.0%Language:Batchfile 0.0%