Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: Workaround for JamesNK/Newtonsoft.Json#862 #110

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The `Unreleased` section name is replaced by the expected version of next releas
### Changed

- `NewtonsoftJson`: Upped minimum `Newtonsoft.Json` version to `13.0.3` per [GitHub advisory database](https://www.nuget.org/packages/newtonsoft.json/11.0.2) [#109](https://github.com/jet/FsCodec/pull/109)
- `NewtonsoftJson.Options`: Change all settings (inc `CreateDefault`) to set `DateParseHandling = DateParseHandling.None` in order to work around [the hare-brained default](https://github.com/JamesNK/Newtonsoft.Json/issues/862) [#110](https://github.com/jet/FsCodec/pull/110)

### 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