Skip to content

Commit

Permalink
fix!: Workaround for JamesNK/Newtonsoft.Json#862
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Nov 30, 2023
1 parent 362853a commit 1f329a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ The `Unreleased` section name is replaced by the expected version of next releas

### Added
### Changed

- `Newtonsoft.Optiinos`: Change all settings (inc `CreateDefault`) to use [`DateParseHandling = DateParseHandling.None` by default in order to [avoid a hare-brained default](https://github.com/JamesNK/Newtonsoft.Json/issues/862) [#108](https://github.com/jet/FsCodec/pull/108)

### Removed
### Fixed

Expand Down
2 changes: 2 additions & 0 deletions src/FsCodec.NewtonsoftJson/Options.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type Options private () =
static member val Default : JsonSerializerSettings = Options.Create()

/// Creates a default set of serializer settings used by Json serialization. When used with no args, same as JsonSerializerSettings.CreateDefault()
/// With one difference - it inhibits the JSON.NET out of the box parsing of strings that look like dates (see https://github.com/JamesNK/Newtonsoft.Json/issues/862)
static member CreateDefault
( [<Optional; ParamArray>] converters : JsonConverter[],
// Use multi-line, indented formatting when serializing JSON; defaults to false.
Expand All @@ -38,6 +39,7 @@ type Options private () =
Converters = converters,
DateTimeZoneHandling = DateTimeZoneHandling.Utc, // Override default of RoundtripKind
DateFormatHandling = DateFormatHandling.IsoDateFormat, // Pin Json.Net claimed default
DateParseHandling = DateParseHandling.None, // Override hare-brained default of DateTime per https://github.com/JamesNK/Newtonsoft.Json/issues/862
Formatting = (if indent then Formatting.Indented else Formatting.None),
MissingMemberHandling = (if errorOnMissing then MissingMemberHandling.Error else MissingMemberHandling.Ignore),
NullValueHandling = (if ignoreNulls then NullValueHandling.Ignore else NullValueHandling.Include))
Expand Down

0 comments on commit 1f329a7

Please sign in to comment.