FSharp.RfcJson
0.0.2
dotnet add package FSharp.RfcJson --version 0.0.2
NuGet\Install-Package FSharp.RfcJson -Version 0.0.2
<PackageReference Include="FSharp.RfcJson" Version="0.0.2" />
<PackageVersion Include="FSharp.RfcJson" Version="0.0.2" />
<PackageReference Include="FSharp.RfcJson" />
paket add FSharp.RfcJson --version 0.0.2
#r "nuget: FSharp.RfcJson, 0.0.2"
#:package FSharp.RfcJson@0.0.2
#addin nuget:?package=FSharp.RfcJson&version=0.0.2
#tool nuget:?package=FSharp.RfcJson&version=0.0.2
FSharp.RfcJson
FSharp.RfcJson is a JSON parser. 遵守Rfc标准
解析成为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
let n = """{
"0":{"index":0,"license":"t","nameSID":"n","image":"img:left","descriptionSID":"t","category":"r"}
}"""
let y =
n
|> Json.parse
|> Json.print
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
|> Json.parse
|> 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 JSON.parse is Json type that is a Discriminated Union type of F#.
RFC Json
Parse RFC-compliant JSON with extreme parsing speed and minimal memory usage.
- Case-insensitive
- Capable of parsing infinity
- Swallows unquoted data as
Json.String
let i = "[\"start\", {\"action\": \"process\", \"data\": [1, 2, 3]}, \"end\"]"
let e = Json.Array
[ Json.String "start"
Json.Object
[ "action", Json.String "process"
"data", Json.Array [ Json.Number 1.0; Json.Number 2.0; Json.Number 3.0 ] ]
Json.String "end" ]
let y = RfcJson.parse i
Should.equal e y
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 (>= 9.0.303)
- FSharp.LexYacc (>= 0.0.5)
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.0.2 | 105 | 10/18/2025 |
first