Skip to content

DateTimeOffset is modified during deserialization #509

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

Closed
milosloub opened this issue May 17, 2019 · 0 comments · Fixed by #510
Closed

DateTimeOffset is modified during deserialization #509

milosloub opened this issue May 17, 2019 · 0 comments · Fixed by #510
Labels

Comments

@milosloub
Copy link
Contributor

milosloub commented May 17, 2019

Description

The problem is on this line

var bodyJToken = JToken.Parse(requestBody);

When using DateTimeOffset type and using JToken.Parse, it is converted to DateTime (so it is modified) as it is hardcoded as a standard behavior, see:
JamesNK/Newtonsoft.Json#862
(it is closed, but still unresolved for JToken.Parse)

Solution is change JToken.Parse to JToken.Load with StringReader and set option DateParseHandling = DateParseHandling.None; (default is DateTime). It is described here:
JamesNK/Newtonsoft.Json#862 (comment)

This issue solved global datetimeoffset destroying data, beacuse there is no option to pass another settings to JToken.Parser to override this default.

Environment

  • JsonApiDotNetCore Version 3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

1 participant