-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
(De)serializing stacks with JsonSerializer should round-trip #31211
Comments
We'll leave the implementation in 3.0 and 3.1, where the stack contents are reversed on serialize, as is. This applies to generic stacks ( In 5.0, we'll possibly make a breaking change where the stack contents are not reversed on serialize by default, which is the expected behavior, and ensures round-tripping. In this case, there'll be an option to instead use the behavior in 3.0/3.1. |
I am writing a
My current version fixes the stack order on deserialization. If I want this to be compatible with 5.0 do I need to modify the code to reverse the items during serialization instead? |
|
@dbc2 - the behavior for master/5.0 is (currently) the same as 3.x. |
This comment has been minimized.
This comment has been minimized.
We shouldn't do this. There's no standard on which side to reverse the items (serialization or deserialization) in order to roundtrip, so it is a non-starter as a breaking change candidate. The current behavior is compatible with Newtonsoft.Json behavior. There's a work item to provide a sample converter showing how to roundtrip in the JSON docs which I think should suffice as a resolution for this issue: dotnet/docs#16690. Here's what this converter could look like - dotnet/docs#16225 (comment). |
The serializer currently doesn't roundtrip i.e serialize -> deserialize -> serialize does not result in the same state.
More discussion:
The text was updated successfully, but these errors were encountered: