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
TejSoft's answer does not work in ASP.NET Core 3.0 Web APIs by default.
Starting in 3.0, the ASP.NET Core Json.NET (Newtonsoft.Json) sub-component is removed from the ASP.NET Core shared framework. It is announced that, "Json.NET will continue to work with ASP.NET Core, but it will not be in the box with the shared framework." The newly added Json Api claimed to be specifically geared for high-performance scenarios.
Use JsonPropertyName attribute to set a custom property name:
using System.Text.Json.Serialization;
public class Package
{
[JsonPropertyName("carrier")]
public string Carrier { get; set; }
[JsonPropertyName("tracking_number")]
public string TrackingNumber { get; set; }
}
Hope it helps!