I am trying to convert dynamic object contains JSON data into custom c# object and get the following error:
RuntimeBinderException The best overloaded method match for Newtonsoft.Json.JsonConvert.DeserializeObject(string, System.Type, params Newtonsoft.Json.JsonConverter[])' has some invalid arguments
The variable named communication is a dynamic object contains the following value (JSON data):
{
"name": "inGame",
"selected": true,
"image": "assets/img/communication/ingame.png"
}
here is the code that should convert the dynamic into a custom c# object:
InGameCommunication inherited = JsonConvert.DeserializeObject(communication, typeof(InGameCommunication),
new JsonSerializerSettings());
The class hierarchy:
public abstract class Communication
{
public int Id { get; set; }
public string Name { get; set; }
public bool Selected { get; set; }
}
public class InGameCommunication : Communication
{
}
public class SkypeCommunication : Communication
{
public string Username { get; set; }
}
communicationat runtime?