AspNetCore.FSharpCompilerJson
1.0.4
Suggested Alternatives
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package AspNetCore.FSharpCompilerJson --version 1.0.4
NuGet\Install-Package AspNetCore.FSharpCompilerJson -Version 1.0.4
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.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AspNetCore.FSharpCompilerJson --version 1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AspNetCore.FSharpCompilerJson, 1.0.4"
#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.0.4 // Install AspNetCore.FSharpCompilerJson as a Cake Tool #tool nuget:?package=AspNetCore.FSharpCompilerJson&version=1.0.4
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
本NuGet包提供把FSharpCompiler.Json
的功能整合进入ASP.NET中,用于替换ASP.NET中内置的Json功能。
用法
新建一个ASP.NET Core Web 应用程序
安装NuGet包:
install-package Microsoft.AspNetCore.SpaServices.Extensions
install-package AspNetCore.FSharpCompilerJson
序列化控制器行为的结果为JSON
修改方法ConfigureServices
,向其中添加依赖注入:
public void ConfigureServices(IServiceCollection services) {
...
FSharpCompilerJsonDependencyInjection.AddFSharpJson(services);
}
这个配置意味着操作返回JsonResult
类型时,ASP.NET会用FSharpCompiler.Json
序列化类型。例如:
[<HttpGet>]
member this.action() =
...
JsonResult data
data将会使用FSharpCompiler.Json
序列化为Json,并放到请求的响应中。
读取Request.Query的方法
在控制器的操作中:
[<HttpGet>]
member this.kvps() =
let kvps = this.Request.Query |> Query.toPairs
...
kvps
的类型是seq<string*string>
,比如请求中的查询字符串:
?foo=bar&baz=[~qux~,~quux~]
对应的kvps为
["foo","bar";"baz","[~qux~,~quux~]"]
Product | Versions 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.
-
net5.0
- FSharp.Core (>= 5.0.1)
- FSharpCompiler.Json (>= 1.1.2)
- TaskBuilder.fs (>= 2.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
update fsharpcompiler.json