我使用的是Newtonsoft,我有这个JSON属性:
[JsonProperty("br")]
public Market Market { get; set; }
但我想将属性的名称设置为变量,如下所示:
string market = TestContext.Parameters["market"];
[JsonProperty(market)]
public Market Market { get; set; }
有办法吗?
答案 0 :(得分:0)
您只需在JSON中使用PropertyName
[JsonProperty(PropertyName = "market")]
public Market Market { get; set; }