What is the equivalent of Newtonsoft.Json's JsonProperty
attribute in System.Text.Json?
Example:
using Newtonsoft.Json;
public class Example
{
[JsonProperty("test2")]
public string Test { get; set; }
}
References:
The property is named JsonPropertyName
and comes from System.Text.Json.Serialization
in the System.Text.Json
package. The functionality is natively available in .NET 3.1 or later.
Example:
using System.Text.Json.Serialization;
public class Example
{
[JsonPropertyName("test2")]
public string Test { get; set; }
}
References: