I am getting json response from some server in format like:
[
{
"email":"john.doe@sendgrid.com",
"sg_event_id":"VzcPxPv7SdWvUugt-xKymw",
"sg_message_id":"142d9f3f351.7618.254f56.filter-147.22649.52A663508.0",
"timestamp":"1386636112",
"smtp-id":"<142d9f3f351.7618.254f56@sendgrid.com>",
"event":"processed",
"category":"category1",
"id": "001",
"purchase": "PO1452297845",
"Segmentid": "123456"
},
{
"email":"not an email address",
"smtp-id":"<4FB29F5D.5080404@sendgrid.com>",
"timestamp":"1386636115",
"reason":"Invalid",
"event":"dropped",
"category":"category2",
"id":"001",
"purchase":"PO1452297845",
"Segmentid":"123456"
},
{
"email":"john.doe@sendgrid.com",
"sg_event_id":"vZL1Dhx34srS-HkO-gTXBLg",
"sg_message_id":"142d9f3f351.7618.254f56.filter-147.22649.52A663508.0",
"timestamp":"1386636113",
"smtp-id":"<142d9f3f351.7618.254f56@sendgrid.com>",
"event":"delivered",
"category":"category1",
"id": "001",
"ip": "174.56.33.234",
"url": "http://www.google.com/",
"purchase": "PO1452297845",
"Segmentid":"123456"
}]
In mvc controller action I am getting these response via model like:
[ValidateInput(false)]
[HttpPost]
public async Task<ActionResult> Index(ResponseModel[] rec)
{
}
My model is like:
public class ResponseModel
{
public int ReportId { get; set; }
public string raw { get; set; }
public int event_post_timestamp { get; set; }
public string SegmentId { get; set; }
public string url { get; set; }
public string type { get; set; }
public string status { get; set; }
public string attempt { get; set; }
public string useragent { get; set; }
public string ip { get; set; }
public string reason { get; set; }
public string response { get; set; }
public string newsletter { get; set; }
public string category { get; set; }
public string sg_message_id { get; set; }
public string sg_event_id { get; set; }
[Column("smtp-id")]
[DataMember(Name="smtp-id")]
[JsonProperty("smtp-id")]
public string smtp_id { get; set; }
public string email { get; set; }
[Column("event")]
[JsonProperty("event")]
[DataMember(Name = "event")]
public string @event { get; set; }
public int timestamp { get; set; }
}
In action I am getting all property initialized but not smtp-id. So please suggest me how can I map response "smtp-id" attribute to my model.