I am trying to pass along a JSON string for an API I'm writing. Here's what the JSON post looks like:
{"AssociatedApplication":"Postman", "Key":"a274e012c52d4121bda7d1e7a7218cf5", "Subject":"Testing API", "Body":"Testing email API. Muffins.",
"EmailAddresses":[
{"From":"[email protected]"},
{"To":"[email protected]"},
{"To":"[email protected]"},
{"Cc":"[email protected]"},
{"Bcc":"[email protected]"}
]
}
Using JSON2Csharp, I have my classes set up as
[NotMapped]
class EmailTransmission
{
public string AssociatedApplication;
public string Key;
public string Subject;
public string Body;
public List<EmailAddress> EmailAddresses;
}
[NotMapped]
public class EmailAddress
{
public string From { get; set; }
public string To { get; set; }
public string Cc { get; set; }
public string Bcc { get; set; }
}
When I use JsonConvert.DeserializeObject<List<EmailAddress>>(email["EmailAddresses"]) it doesn't work and I've tried List<List<string>> List and so forth. What is the type I should use without getting a runtime type binder exception?