JsonTag.FSharp 0.1.7

dotnet add package JsonTag.FSharp --version 0.1.7
                    
NuGet\Install-Package JsonTag.FSharp -Version 0.1.7
                    
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="JsonTag.FSharp" Version="0.1.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JsonTag.FSharp" Version="0.1.7" />
                    
Directory.Packages.props
<PackageReference Include="JsonTag.FSharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add JsonTag.FSharp --version 0.1.7
                    
#r "nuget: JsonTag.FSharp, 0.1.7"
                    
#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.
#:package JsonTag.FSharp@0.1.7
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=JsonTag.FSharp&version=0.1.7
                    
Install as a Cake Addin
#tool nuget:?package=JsonTag.FSharp&version=0.1.7
                    
Install as a Cake Tool

json-tag

F# support for JSON#.

Configures FSharp.SystemTextJson to use the JSON# convention.

Install

dotnet add package JsonTag.FSharp

Usage

Define your discriminated unions:

type Shape =
    | Circle of radius: float
    | Rectangle of width: float * height: float

Serialize and deserialize:

let json = JsonSerializer.Serialize(Circle(radius = 4.0), JsonTagOptions.Default)
// {"#type":"Circle","radius":4}

let shape = JsonSerializer.Deserialize<Shape>(json, JsonTagOptions.Default)

Custom tag names (using FSharp.SystemTextJson's JsonName attribute):

type Vehicle =
    | [<JsonName("Car")>] PersonalVehicle of make: string
    | [<JsonName("Truck")>] TransportationVehicle of payloadTons: float

Apply to existing JsonFSharpOptions:

let myFSharpOptions = JsonFSharpOptions(unionEncoding = JsonUnionEncoding.UnwrapOption)
let options = JsonTagOptions.apply myFSharpOptions

ASP.NET Core / Giraffe:

builder.Services.ConfigureHttpJsonOptions(fun options ->
    options.SerializerOptions <- JsonTagOptions.Default)

API

Export Description
JsonTagOptions.Default Pre-configured JsonSerializerOptions
JsonTagOptions.apply Applies #type convention to existing JsonFSharpOptions
[<JsonName("X")>] Custom #type value on a union case (from FSharp.SystemTextJson)

Known limitation

FSharp.SystemTextJson requires #type to be the first property in the JSON object. Out-of-order #type is not supported.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.7 110 3/30/2026
0.1.6 104 3/30/2026
0.1.5 95 3/30/2026
0.1.4 107 3/30/2026
0.1.2 97 3/30/2026
0.1.1 105 3/30/2026