Specifying custom property name when binding object to Web API endpoint

前端 未结 7 916

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 clas         


        
7条回答
  •  天涯浪人
    2020-12-09 15:54

    For DotnetCore3.1 We can use

    public class Package
    {
    
        [JsonProperty("carrier")]
        public string Carrier { get; set; }
    
        [JsonProperty("trackingNumber")]
        public string TrackingNumber { get; set; }
    }
    

提交回复
热议问题