Skip to content

Commit

Permalink
Release version 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Mangel committed Oct 24, 2019
1 parent 3e8c51c commit 5997823
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 440 deletions.
Binary file modified .ionide/symbolCache.db
Binary file not shown.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

## 2.3.0

### Added

* Add `skipNullField` options to pass to `Encode.Auto`

## 2.2.0

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ source https://www.nuget.org/api/v2
storage: none

nuget FSharp.Core redirects:force, content:none
nuget Giraffe
nuget Giraffe >= 3.6 lowest_matching:true
nuget Thoth.Json.Net
568 changes: 134 additions & 434 deletions paket.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Thoth.Json.Giraffe.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<RepositoryUrl>https://github.com/MangelMaxime/Thoth</RepositoryUrl>
<PackageTags>fsharp;json;Giraffe;ASP.NET;Core</PackageTags>
<Authors>Maxime Mangel</Authors>
<Version>2.2.0</Version>
<Version>2.3.0</Version>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
Expand Down
8 changes: 4 additions & 4 deletions src/ThothSerializer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open Giraffe
open Giraffe.Serialization.Json
open Thoth.Json.Net

type ThothSerializer (?isCamelCase : bool, ?extra: ExtraCoders) =
type ThothSerializer (?isCamelCase : bool, ?extra : ExtraCoders, ?skipNullField : bool) =
static let Utf8EncodingWithoutBom = new UTF8Encoding(false)
static let DefaultBufferSize = 1024

Expand Down Expand Up @@ -77,7 +77,7 @@ type ThothSerializer (?isCamelCase : bool, ?extra: ExtraCoders) =
interface IJsonSerializer with
member __.SerializeToString (o : 'T) =
let t = if isNull <| box o then typeof<'T> else o.GetType()
let encoder = Encode.Auto.LowLevel.generateEncoderCached(t, ?isCamelCase=isCamelCase, ?extra=extra)
let encoder = Encode.Auto.LowLevel.generateEncoderCached(t, ?isCamelCase=isCamelCase, ?extra=extra, ?skipNullField=skipNullField)
encoder o |> Encode.toString 0

member __.Deserialize<'T> (json : string) =
Expand Down Expand Up @@ -109,7 +109,7 @@ type ThothSerializer (?isCamelCase : bool, ?extra: ExtraCoders) =

member __.SerializeToBytes<'T>(o : 'T) : byte array =
let t = if isNull <| box o then typeof<'T> else o.GetType()
let encoder = Encode.Auto.LowLevel.generateEncoderCached(t, ?isCamelCase=isCamelCase, ?extra=extra)
let encoder = Encode.Auto.LowLevel.generateEncoderCached(t, ?isCamelCase=isCamelCase, ?extra=extra, ?skipNullField=skipNullField)
// TODO: Would it help to create a pool of buffers for the memory stream?
use stream = new MemoryStream()
use writer = new StreamWriter(stream, Utf8EncodingWithoutBom, DefaultBufferSize)
Expand All @@ -126,6 +126,6 @@ type ThothSerializer (?isCamelCase : bool, ?extra: ExtraCoders) =
upcast task {
use streamWriter = new System.IO.StreamWriter(stream, Utf8EncodingWithoutBom, DefaultBufferSize, true)
use jsonWriter = new JsonTextWriter(streamWriter)
let encoder = Encode.Auto.generateEncoderCached<'T>(?isCamelCase=isCamelCase, ?extra=extra)
let encoder = Encode.Auto.generateEncoderCached<'T>(?isCamelCase=isCamelCase, ?extra=extra, ?skipNullField=skipNullField)
do! (encoder o).WriteToAsync(jsonWriter)
}

0 comments on commit 5997823

Please sign in to comment.