I have a class like below
[Serializable] public class sample { private int m_width; private int m_height; public int Width { get { return this.m_width; } set { this.m_width = value; } } public int Height { get { return this.m_height; } set { this.m_height = value; } } }
If I use a DataContractJsonSerializer to serialize an object of this class, I get a json string, as shown below:
{"m_height":1345,"m_width":1234}
If I use Newtonsoft.Json.dll for serialization, I get the following code:
{"Width":1234,"Height":1345}
Why does the DataContractSerializer use fallback fields for serialization if the class is marked as serializable?
Is there a way that I can achieve the same using Newtonsoft.Json.dll
source share