I have an class like this:
[JsonObject(MemberSerialization.OptIn)]
public class Event
{
[JsonProperty]
public Guid EventID;
public string Source;
public UInt64? EventCode;
public DateTime? TimeStamp;
[JsonProperty]
public string SourceType;
...
}
and a web api2 controller like this:
[HttpPost]
public IHttpActionResult Post([FromBody]Event @event) { ... }
My problem is that even though all Event parameters are provided in the Post call, the Source, EventCode and TimeStamp are left out. They are left out due to the JsonProperty annotation. But they are in place as the object later is serialized where only the annotated values should be serialized.
So, how do I get all properties deserialized but only some serialized?