JSON Serialization in WCF - Are Object Properties Ordered Alphabetically?

I created a WCF REST service that returns JSON, but the properties in serialized objects are returned in alphabetical order.

Is it possible to change this?

+3
source share
1 answer

Try setting the order property on your data elements for your data contracts:

[DataContract]
public class MyClass
{
     [DataMember(IsRequired = true, Order = 1)]
     public int Id { get; set; }
}
+5
source

Source: https://habr.com/ru/post/1763823/


All Articles