I have a class which Implements IEnumerable and another Interface IModel:
public class Model : IEnumerable, IModel {
private readonly List<string> list = new List<string> {"aa", "bb"};
public IEnumerator GetEnumerator() {
return this.list.GetEnumerator();
}
public string Name { get; set; }
}
When I call
JsonConvert.SerializeObject(new Model() { Name = "Test" });
Json.NET is only serializing the Elements of the List. The Result is:
["aa","bb"]
What do I have to do, that Json.NET will also serialize the Property Name? Note: This is only a small Sample and I cannot change the original class because I am not the developer of the class.