【问题标题】:Colon in C# List definition [duplicate]C#列表定义中的冒号[重复]
【发布时间】:2014-12-18 10:34:49
【问题描述】:

我必须反序列化一个在根对象名称中包含冒号的 JSON 对象数组。

有谁知道我是否可以在列表定义中使用冒号以某种方式实现这一点?

public List<Customers> ngcp:customers { get; set; }

【问题讨论】:

    标签: c# json.net


    【解决方案1】:

    不,正确的方法是使用 json.net 支持的属性或其他方法指定名称。

    [JsonProperty(PropertyName = "ngcp:customers")]
    public List<Customers> Customers { get; set; }
    

    【讨论】:

    • 谢谢,您能帮我处理一下 ngcp:customers 的对象集合吗?我想获取该集合中的每个对象并将其用于数据网格:
    猜你喜欢
    • 2014-11-24
    • 2011-04-30
    • 1970-01-01
    • 2011-01-27
    • 2012-10-15
    • 1970-01-01
    • 2019-06-30
    • 2011-04-28
    • 1970-01-01
    相关资源
    最近更新 更多