Skip to content

Commit 4f93c6c

Browse files
committed
doc: Giraffe v7 FSharpFriendlySerializer
1 parent 4562032 commit 4f93c6c

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

docs/Using.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ type MyTestController() =
108108

109109
To use FSharp.SystemTextJson in Giraffe (for example with the `json` function):
110110

111-
* With Giraffe 5.x or newer, add the following to your `configureServices` function:
111+
* With Giraffe 7.x, `FSharp.SystemTextJson` is supported out of the box using the `FSharpFriendlySerializer`:
112112

113113
```fsharp
114114
open System.Text.Json
@@ -120,6 +120,23 @@ To use FSharp.SystemTextJson in Giraffe (for example with the `json` function):
120120
121121
let jsonOptions =
122122
JsonFSharpOptions.Default()
123+
// .Add customizations here...
124+
services.AddSingleton<Json.ISerializer>(Json.FsharpFriendlySerializer(jsonOptions)) |> ignore
125+
```
126+
127+
* With Giraffe 5.x or 6.x, add the following to your `configureServices` function:
128+
129+
```fsharp
130+
open System.Text.Json
131+
open System.Text.Json.Serialization
132+
open Giraffe
133+
134+
let configureServices (services: IServiceCollection) =
135+
services.AddGiraffe() |> ignore
136+
137+
let jsonOptions =
138+
JsonFSharpOptions.Default()
139+
// .Add customizations here...
123140
.ToJsonSerializerOptions()
124141
services.AddSingleton<Json.ISerializer>(SystemTextJson.Serializer(jsonOptions)) |> ignore
125142
// ...

0 commit comments

Comments
 (0)