I have a .Net Core Web API. It automatically maps models when the model properties match the request body. For example, if you have this class:
public class Package
{
public string Carrier { get; set; }
public string TrackingNumber { get; set; }
}
It would correctly bind it to a POST endpoint if the request body is the following JSON:
{
carrier: "fedex",
trackingNumber: "123123123"
}
What I need to do is specify a custom property to map. For example, using the same class above, I need to be able to map to JSON if the TrackingNumber comes in as tracking_number
.
How do I do that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…