将JSON反序列化为C#对象

希特什
{"facet_counts":{
  "facet_queries":{},
  "facet_fields":{},
  "facet_dates":{},
  "facet_ranges":{
    "createdat":{
      "counts":[
        "2015-05-17T00:00:00Z",155,
        "2015-05-18T00:00:00Z",162,
        "2015-05-19T00:00:00Z",200,
        "2015-05-20T00:00:00Z",218,
        "2015-05-21T00:00:00Z",181,
        "2015-05-22T00:00:00Z",137],
      "gap":"+1DAY",
      "start":"2015-05-17T00:00:00Z",
      "end":"2015-05-23T00:00:00Z"}}}}

我正在尝试将上述json反序列化为对象,但是count部分没有反序列化。我的对象是

public class FacetCounts
{
    public class Facet_Ranges
    {
        public class CreatedAt
        {
            public List<Counts> counts { get; set; }
            public class Counts
            {
                public Dictionary<string, int> count { get; set; }
            }
        }
        public CreatedAt createdat { get; set; }
    }
    public Facet_Ranges facet_ranges { get; set; }
}

我也尝试删除,public Dictionary<string, int> count { get; set; }但仍然失败。我的反序列化代码是

objObject = JsonConvert.DeserializeObject<FacetCounts>(json);

任何帮助,将不胜感激 !!

希特什

来自JSON2CSHARP

public class Createdat
{
    public List<object> counts { get; set; }
    public string gap { get; set; }
    public string start { get; set; }
    public string end { get; set; }
}

这对我有用

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章