Newtonsoft.Json/Json.Net 在 System.Text.Json 中的 JsonProperty 字段等效于什么?

What is the equivalent of Newtonsoft.Json's / Json.Net's JsonProperty field in System.Text.Json?

我想知道 Newtonsoft.Json 的/Json.Net 的 JsonProperty 字段在 System.Text.Json 中的等效项是什么。

示例:

using Newtonsoft.Json;

public class Example
{
    [JsonProperty("test2")]
    public string Test { get; set; }
}

参考文献:

以防万一,其他任何人都摔倒了。 属性 重命名为 JsonPropertyName 并来自 System.Text.Json nuget 包中的 System.Text.Json.Serialization

示例:

using System.Text.Json.Serialization;

public class Example
{
    [JsonPropertyName("test2")]
    public string Test { get; set; }
}

参考文献: