giraffe-fsharp / Giraffe

A native functional ASP.NET Core web framework for F# developers.
https://giraffe.wiki
Apache License 2.0
2.11k stars 267 forks source link

F# compatible json serializer #604

Closed fpellet closed 1 month ago

fpellet commented 1 month ago

With the change https://github.com/giraffe-fsharp/Giraffe/issues/560 , unlike before, by default the serializer is not compatible with the particularities of F#. As this can have an impact on performance, I can understand not setting a compatible serializer by default, even if I think it's a shame for a project like Giraffe. Nevertheless, I suggest making things easier and offering a configuration via FSharp.SystemTextJson for example directly via the project so as not to add a barrier.

64J0 commented 1 month ago

Thanks for opening this PR @fpellet.

Nevertheless, I suggest making things easier and offering a configuration via FSharp.SystemTextJson for example directly via the project so as not to add a barrier.

Fair enough, I like this idea!

forki commented 1 month ago

adding to this the current docs are broken:

image

that thing can't be found.

fpellet commented 1 month ago

For FSharp.SystemTextJson , I'll have a look this weekend.

@forki indeed, I had seen that and forgot to put it back up.

Necessary changes in the doc: It need to delete this constructor, and initialize in services:

services.AddSingleton<Json.ISerializer>(fun serviceProvider ->
            NewtonsoftJson.Serializer(JsonSerializerSettings(), serviceProvider.GetService<Microsoft.IO.RecyclableMemoryStreamManager>()) :> Json.ISerializer) |> ignore
64J0 commented 1 month ago

I think it makes sense to add a new sample to this project showing how to add NewtonsoftJson back properly.

fpellet commented 1 week ago

@64J0 It's possible to publish new version? 😊

nojaf commented 1 week ago

As in new NuGet or publish documentation? (For NuGet 7.0.0 is published right? https://www.nuget.org/packages/Giraffe/7.0.0)

fpellet commented 1 week ago

Nuget to use new serialiser without copy paste

64J0 commented 1 week ago

@64J0 It's possible to publish new version? 😊

Sure, working on it right now.

64J0 commented 1 week ago

Version 7.0.1 released 🚀 https://www.nuget.org/packages/Giraffe/7.0.1