FSharp.RfcJson
0.0.3
dotnet add package FSharp.RfcJson --version 0.0.3
NuGet\Install-Package FSharp.RfcJson -Version 0.0.3
<PackageReference Include="FSharp.RfcJson" Version="0.0.3" />
<PackageVersion Include="FSharp.RfcJson" Version="0.0.3" />
<PackageReference Include="FSharp.RfcJson" />
paket add FSharp.RfcJson --version 0.0.3
#r "nuget: FSharp.RfcJson, 0.0.3"
#:package FSharp.RfcJson@0.0.3
#addin nuget:?package=FSharp.RfcJson&version=0.0.3
#tool nuget:?package=FSharp.RfcJson&version=0.0.3
FSharp.RfcJson
FSharp.RfcJson is a JSON parser. 遵守Rfc标准
Parse RFC-compliant JSON with extreme parsing speed and minimal memory usage.
- Case-insensitive
- Capable of parsing infinity
- Swallows unquoted data as
Json.String
解析成为FSharp对象
namespace FSharp.Idioms.Jsons
[<RequireQualifiedAccess>]
type Json =
| Object of entries:list<string*Json>
| Array of elements:list<Json>
| Null
| False
| True
| String of text: string
| Number of value: float
基本用法:
let x = """{
0:{index:0, license:t, nameSID:n, image:"img:left", descriptionSID:t, category:r}
}"""
let y:Json = FSharp.RfcJson.JsonCompiler.compile x
let z:string = FSharp.Idioms.Jsons.Json.print y
Object Serialization
You can define serialization and deserialization functions for objects.
let serialize<'t> obj =
obj
|> Json.read<'t>
|> Json.print
let deserialize<'t> text =
text
|> JsonCompiler.compile
|> Json.write<'t>
Here are some examples of serialization of common object types.
Tuple
(1,"x")
[1,"x"]
Array, list, Set and so on
[1;2;3]
[1,2,3]
Record
Supports serialization of anonymous records also.
{ name = "abcdefg"; age = 18 }
{"name":"abcdefg","age":18}
Map
Map [1,"1";2,"2"]
[[1,"1"],[2,"2"]]
Option
[Some 1;None]
[[1],[]]
Union
type UionExample =
| Zero
| OnlyOne of int
| Pair of int * string
[Zero;OnlyOne 1;Pair(2,"b")]
["Zero";["OnlyOne", 1];["Pair",2,"b"]]
Provide tryRead and tryWrite to custom your convert rule
The signature of tryRead is:
tryRead:Type -> obj -> ((Type -> obj -> Json) -> Json) option
The signature of tryWrite is:
tryWrite:Type -> Json -> ((Type -> Json -> obj) -> obj) option
The usage see also FSharpConverter.fs
The return value of JsonCompiler.compile is Json type that is a Discriminated Union type of F#.
UrlQuery
FSharp.RfcJson can be used for query strings in URLs. When the field is of primitive type, the query string format is used. When the field is a complex type, use the Unqoted Json format.
The source see UrlQuery
The usage see also UrlQueryTest.fs
| Product | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
| .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 | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. 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. |
-
.NETStandard 2.0
- FSharp.Core (>= 10.1.301)
- FSharp.LexYacc (>= 0.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
update packages