I'm trying to deserialize the JSON that gets posted from GitHubs webhook for a push event.
It uses a "ref" property to store the branch information, but ref is a reserved word in C# so the serialization isn't working.
Right now I have
public class PushEvent
{
[JsonProperty("ref")]
public string _ref { get; set; }
public string before { get; set; }
public string after { get; set; }
public bool created { get; set; }
public bool deleted { get; set; }
public bool forced { get; set; }
public object base_ref { get; set; }
public string compare { get; set; }
public Commit[] commits { get; set; }
public Head_Commit head_commit { get; set; }
public Repository repository { get; set; }
public Pusher pusher { get; set; }
public Sender sender { get; set; }
}
but _ref is always set to null. For reference, also, here is the MVC action that writes the pushed data to a file - just in case that makes a difference
[HttpPost]
public JsonResult PushEvent(PushEvent data)
{
var dataString = JsonConvert.SerializeObject(data);
using(var writer = System.IO.File.CreateText(Server.MapPath("/app_data/" + DateTime.UtcNow.ToString("yyyyMMddhhmmss") + ".json")))
{
writer.Write(dataString);
}
return new JsonResult(){Data="ok"};
}