Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
C# 不允许使用空格等特殊字符的属性名称。需要有一种方法来定义这样的 json 对象。任何想法 ?
{ ".Class1 #Id1" : "Value1" ".Class1 #Id2" : "Value2" }
尝试使用 JsonProperty 属性:
public class MyClass { [JsonProperty(".Class1 #Id1")] public string id1 { get; set; } [JsonProperty(".Class1 #Id2")] public string id2 { get; set; } }