在System.Text.Json中,Newtonsoft.Json / Json.Net的JsonProperty字段相当于什么? - c#

我想知道System.Text.Json中Newtonsoft.Json / Json.Net的JsonProperty字段是什么。
例:

using Newtonsoft.Json;

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

参考文献:
Newtonsoft.Json JsonProperty
Using Newtonsoft.Json attributes

参考方案

以防万一,还有其他人对此感到失望。该属性被重命名为JsonPropertyName,并且来自System.Text.Json.Serialization nuget包中的System.Text.Json

例:

using System.Text.Json.Serialization;

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

参考文献:

Try the new System.Text.Json APIs
JsonProperty.Name Property --> Not yet documented properly...

新的`System.Text.Json`是否具有必需的属性属性? - c#

我已经梳理了MS docs,但是找不到与NewtonSoft JsonPropertyRequired等效的属性。我在寻找什么:public class Videogame { [JsonProperty(Required = Required.Always)] public string Name { get; set; } } 我只是缺少什么吗?Micr…

System.Text.Json合并两个对象 - c#

是否可以用System.Text.Json?合并两个这样的json对象对象1{ id: 1 william: "shakespeare" } 对象2{ william: "dafoe" foo: "bar" } 结果对象{ id: 1 william: "dafoe" foo: …

json_encode网址失败 - php

有人在this bug附近吗?echo json_encode(array('url'=>'/foo/bar')); {"url":"\/foo\/bar"} 我使用Zend_Json and Zend_Json_Expr以便我甚至可以在js对象中获取回调函数-但我无法获得…

Javascript和Python JSON-未定义变量 - javascript

例如,如果您具有以下JSON对象(删除python的分号):values = { a: 1, b: { c: 2, d: { e: 3 } }, f: 4, g: 5 }; 如果您尝试在JS中打印values,它将正常工作。但是在Python中,它将返回错误NameError: name 'a' is not defined,这意味着未定…

json.dumps弄乱顺序 - python

我正在使用json module创建一个包含类似条目的json文件json.dumps({"fields": { "name": "%s", "city": "%s", "status": "%s", "cou…