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
Non-Null default value leads to invalid cache value being assigned #2923
Comments
In case you're wondering why I'm assigning an empty default value in the first place:
|
Disclaimer: I am just a user of the library and not associated with the project nor its author/maintainer. Not a bug. It's the default for the ObjectCreationHandling setting in action. It's a bit unfortunate that this particular behavior has been chosen the default behavior, because it (unsurprisingly) catches quite a few users by surprise, but that choice had been made quite long ago, and with so many software projects relying on Newtonsoft.Json it is rather unlikely that a default setting will change... :( In your case, both the In other words, you see the same value for To instruct Newtonsoft.Json to not reuse object instances but replace existing object instances with new ones, either set the P.S.: It is probably a good idea to spend a little time studying the default values used for the serialization settings used by the (de)serializer. Because there might be other default settings (and thus default behavior) of Newtonsoft.Json that you might or might not intuitively expect... |
Destination types
Source JSON
Expected behavior
result.FirstContained.DifferentValue
differs fromresult.SecondContained.DifferentValue
Actual behavior
DifferentValue
always has the value which last occured in the input JSONSteps to reproduce
Workaround
Do not assign a default-value to objects (remove the
= Contained.Empty;
).Thank you for looking into this.
The text was updated successfully, but these errors were encountered: