JSON array deserialization -- is the order of elements always preserved?
When deserializing a JSON array in C#/.NET, is the order 开发者_如何学运维of elements always preserved?
Edit: The library currently being used is .NET 3.5's System.Runtime.Serialization.Json.DataContractJsonSerializer
Yes.
The JSON spec does specify that the order is preserved for arrays as they are an ordered collection of values: JSON.org
I would say it depends on implementation of your library of choice for the task. I your library documentation does not say anything on the matter, I would assume that it is implementation details and can not be trusted(can be changed in next version).
精彩评论