Skip to content

Is it possible to retain the order of the object when serializing #974

Answered by EdwardCooke
devantler asked this question in Q&A
Discussion options

You must be logged in to vote

My guess, based on your example, is that it has something to do with this line in that library that is causing you problems:

.WithTypeConverter(new SystemTextJsonYamlTypeConverter(sortAlphabetically))

Our library typically serializes in the order of the properties as they are declared in the class by default. But there's no guarantees. It's really in whatever order they are returned in the reflection calls or dictionary/list.

Replies: 7 comments 9 replies

Comment options

You must be logged in to vote
1 reply
@devantler
Comment options

Comment options

You must be logged in to vote
2 replies
@devantler
Comment options

@devantler
Comment options

Answer selected by devantler
Comment options

You must be logged in to vote
1 reply
@devantler
Comment options

Comment options

You must be logged in to vote
1 reply
@devantler
Comment options

Comment options

You must be logged in to vote
1 reply
@devantler
Comment options

Comment options

You must be logged in to vote
3 replies
@EdwardCooke
Comment options

@devantler
Comment options

@devantler
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants