AspNetCore.FSharpCompilerJson 1.2.0

Suggested Alternatives

AspNetCore.UnquotedJson

dotnet add package AspNetCore.FSharpCompilerJson --version 1.2.0
NuGet\Install-Package AspNetCore.FSharpCompilerJson -Version 1.2.0
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="AspNetCore.FSharpCompilerJson" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AspNetCore.FSharpCompilerJson --version 1.2.0
#r "nuget: AspNetCore.FSharpCompilerJson, 1.2.0"
#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 AspNetCore.FSharpCompilerJson as a Cake Addin
#addin nuget:?package=AspNetCore.FSharpCompilerJson&version=1.2.0

// Install AspNetCore.FSharpCompilerJson as a Cake Tool
#tool nuget:?package=AspNetCore.FSharpCompilerJson&version=1.2.0

AspNetCore.FSharpCompilerJson

This NuGet package provides the ability to integrate the FSharpCompiler.Json into the ASP.NET to replace the built-in Json serializer.

The Usage

Build an ASP.NET Core Web App, and install following NuGet packages:

install-package Microsoft.AspNetCore.SpaServices.Extensions
install-package AspNetCore.FSharpCompilerJson

How to serialize The return value of the controller's actions as JSON

in Startup.cs file, Modify the method ConfigureServices to add dependency injection to it:

public void ConfigureServices(IServiceCollection services) {
    ...
    FSharpCompilerJsonDependencyInjection.AddFSharpJson(services);
}

This configuration means that FSharpCompiler.Json has been integrated into ASP.NET to replace the built-in json serializer.

[<HttpGet>]
member this.action() = 
    ...
    JsonResult data

data will be serialized as json using the FSharpCompiler.Json serializer, which is ASP.NET's serializer.

The Method to read Request.Query

In a controller's actions, The Method to read Request.Query is as follows:

[<HttpGet>]
member this.kvps() = 
    let kvps = this.Request.Query |> Query.toPairs
    ...

where the type of kvps is seq<string*string>.

For example, a request's url query string is:

?foo=bar&baz=[`qux`,`quux`]

The kvps corresponding to the query string are parsed as follows:

["foo","bar";"baz","[`qux`,`quux`]"]
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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. 
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
1.2.0 578 11/29/2021
1.0.8 560 10/27/2021
1.0.7 591 10/25/2021
1.0.6 600 7/23/2021
1.0.5 540 7/19/2021
1.0.4 541 6/21/2021
1.0.3 655 4/14/2021
1.0.2 726 4/7/2021
1.0.1 741 4/1/2021
1.0.0 545 3/31/2021

migrate to FslexFsyacc