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!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…