Having trouble finding the right way to describe the issue to find a solution for it. But here's a quick rundown.
I'm using Newtonsoft Json plugin for the following:
A Json is being deserialized based on a 'template' which looks like:
public class Json
{
public class Item
{
public string name { get; set; }
public int id { get; set; }
....
public List<Content> content{ get; set; }
public List<IContent> ItemContents = new List<IContent>();
}
public class Content
{
<properties of contents>
}
}
I want the interface of ItemContents to not be loaded/used during de serialization of the Json. At the moment it throws a "Type is an interface or abstract class and cannot be instantiated" error, obviously.
Contents and ItemContents are used in different ways, so I need both at the moment, it may change in the future, but for now, I need ItemContents to be part of Items when de-serialized, but not touched or used as part of that 'template', in the process (if that makes sense).
The idea is that the interfaces should be part of a list that is created during the loading process as part of the Items, to be ready for use when it comes to that.
ItemContentswith the attribute[JsonIgnore]and use the constructor to build it, or in a Serialization Callback?