XmlSerializer vs DataContractSerializer
Asked Answered
O

2

3

I just realized that DataContractSerializer expects nodes in the alphabetical order or the specified order. Is there any way i could make it NOT do it?

TIA

Ordovician answered 25/8, 2010 at 22:29 Comment(0)
O
3

I used IDispatchMessageInspector.AfterReceiveRequest to intercept the message and sort it alphabetically.

Ordovician answered 22/9, 2010 at 22:28 Comment(1)
This is a good idea. In my case, my serialized object inherits from another serialized object. So the tags for the base class come first (in alphabetical) and then the tags for the derived class (in alphabetical order). So, sorting doesn't quite work for that kind of situation.Spaulding
O
4

I don't think so. You may find the discussion on this question informative:

Ignore field order in DataContractSerializer

Overdye answered 25/8, 2010 at 23:14 Comment(0)
O
3

I used IDispatchMessageInspector.AfterReceiveRequest to intercept the message and sort it alphabetically.

Ordovician answered 22/9, 2010 at 22:28 Comment(1)
This is a good idea. In my case, my serialized object inherits from another serialized object. So the tags for the base class come first (in alphabetical) and then the tags for the derived class (in alphabetical order). So, sorting doesn't quite work for that kind of situation.Spaulding

© 2022 - 2024 — McMap. All rights reserved.