Microsoft.FSharpLu 0.10.30

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Microsoft.FSharpLu --version 0.10.30                
NuGet\Install-Package Microsoft.FSharpLu -Version 0.10.30                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.FSharpLu" Version="0.10.30" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.FSharpLu --version 0.10.30                
#r "nuget: Microsoft.FSharpLu, 0.10.30"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.FSharpLu as a Cake Addin
#addin nuget:?package=Microsoft.FSharpLu&version=0.10.30

// Install Microsoft.FSharpLu as a Cake Tool
#tool nuget:?package=Microsoft.FSharpLu&version=0.10.30                


Newtonsoft's Json.Net is the library of choice for Json serialization. Unfortunately the built-in converters generate rather verbose and ugly Json for certain F# data types like discriminated unions and option types. The module Microsoft.FSharpLu.Json provides more succinct serialization for those types.

To use our serializer open the module with

open Microsoft.FSharpLu.Json

To serialize an object using the default Json.Net format you can use Default.serialize.

Option type

The following examples shows how serializes a simple value of type (int option) list:

Default.serialize [Some 5; None; Some 6]

val it : string = "
        "Case": "Some",
        "Fields": [ 5 ]
        "Case": "Some",
        "Fields": [ 6 ]

Using the compact serializer provided by FSharpLu.Json the same objects gets serialized instead as a one-liner heterogeneous array:

Compact.serialize [Some 5; None; Some 6]

val it : string = "[ 5, null, 6 ]"

Discriminated unions

Now let's take a look at simple field-less discriminated unions. Take for instance the type type SimpleDu = Foo | Bar. The value Foo gets serialized by Json.Net as follows:

Value Default ( Compact
Foo { "Case": "Foo" } "Foo"

Discriminated unions with fields

Our serializer also supports generic discrimnated unions with fields for instance take the following binary Tree example:

type 'a Tree = Leaf of 'a | Node of 'a Tree * 'a Tree
let x = Node (Node((Leaf 1), (Leaf 4)), Leaf 6)

Default serialization:

Default.serialize x

val it : string = "
    "Case": "Node",
    "Fields": [
            "Case": "Node",
            "Fields": [
                        "Case": "Leaf",
                        "Fields": [ 1 ]
                        "Case": "Leaf",
                        "Fields": [ 4 ]
            "Case": "Leaf",
            "Fields": [ 6 ]
        } ]

where FSharpLu.Json produces the more succinct and easier to read:

Compact.serialize x

val it : string = "
    "Node": [
            "Node": [
                { "Leaf": 1 },
                { "Leaf": 4 }
        { "Leaf": 6 }

Backward compatibility with Json.Net

FSharpLu.Json incldues a third serializer called BackwardCompatible. While it produces the same Json as the compact serializer it can deserialize Json in both compact format as well as the default format produced by the stock serializer.

This is helpful when migrating projects from Json.Net to FSharpLu.Json as it lets you deserialize Json that was produced by earlier versions of your code.

Expressed more formally this serializer verifies the following properties:

  • BackwardCompatible.serialize = Compact.serialize
  • Default.serialize >> BackwardCompatible.deserialize = id
  • Compact.serialize >> BackwardCompatible.deserialize = id
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net452 is compatible.  net46 was computed.  net461 is compatible.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Microsoft.FSharpLu:

Package Downloads

Windows specific helpers requiring the full .NetFramework


Functional F# library to access Firestore database via Google Cloud Platform (GCP) or Firebase Project.


Azure Management Helpers API for F#

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.11.7 28,975 6/24/2021
0.11.6 27,572 10/20/2019
0.11.5 3,136 8/17/2019
0.11.4 1,409 8/3/2019
0.11.3 1,042 8/1/2019
0.11.2 1,041 7/25/2019
0.11.1 1,098 7/20/2019
0.11.0 872 7/15/2019
0.10.33 1,054 6/25/2019
0.10.32 1,003 6/7/2019
0.10.31 1,337 3/20/2019
0.10.30 953 3/7/2019
0.10.29 3,770 12/27/2018
0.10.28 788 12/15/2018
0.10.27 10,010 6/9/2018
0.10.26 1,195 5/16/2018
0.10.21 1,490 4/27/2018
0.10.4 1,164 2/28/2018
0.10.3 1,343 8/28/2017
0.9.6050.26231 3,006 7/29/2016

Signed assemblies and nuget package