Browse Source

Revert to Utf8Json for serialization (#5211)

Stuart Lang 5 years ago
parent
commit
851c9282c4
1 changed files with 3 additions and 2 deletions
  1. 3 2
      frameworks/FSharp/giraffe/src/App/Custom.fs

+ 3 - 2
frameworks/FSharp/giraffe/src/App/Custom.fs

@@ -44,12 +44,13 @@ let application : HttpHandler =
     let inline contentLength x = new Nullable<int64> ( int64 x )
 
     let json' data : HttpHandler =
+        let bytes = Utf8Json.JsonSerializer.Serialize(data)
         fun _ ctx -> 
-            ctx.Response.ContentLength <- contentLength BufferSize
+            ctx.Response.ContentLength <- contentLength bytes.Length
             ctx.Response.ContentType <- "application/json"
             ctx.Response.StatusCode <- 200
             task {
-                do! System.Text.Json.JsonSerializer.SerializeAsync(ctx.Response.Body, data)
+                do! ctx.Response.Body.WriteAsync(bytes, 0, bytes.Length)
                 return Some ctx
             }