newtonsoft json does not serialize derived class properties

烂漫一生 提交于 2019-12-10 21:52:51

问题


I have a class structure:

public class main
{
derived[Serializable]
    public class Parameters: Service.Parameters {
        public bool a { get; set; }
        public string b { get; set; }
   }
}

I am using:

string jsonSerializedObject = JsonConvert.SerializeObject(model.Parameters, Formatting.None, new JsonSerializerSettings
            {
                TypeNameHandling = TypeNameHandling.Objects,

            });   

But the properties a and b not being serialized. Any idea would be great Thank you

来源:https://stackoverflow.com/questions/18461164/newtonsoft-json-does-not-serialize-derived-class-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!