【问题标题】:How to deserialize Json without property name .net core newtonsoft如何反序列化没有属性名称的 Json .net core newtonsoft
【发布时间】:2022-01-01 08:24:12
【问题描述】:

如果响应如下如何映射:

我的映射类是这样定义的:

public class Data
{   
    public Position positions { get; set; }
}    


[JsonArray]
public class Positions
{
    public string[] value { get; set; }
   
}

但结果是这样的错误:

JsonSerializationException:无法创建和填充列表类型 LifeMatrix.Controllers.Positions。路径 'data[0].positions',第 71 行,位置 17。

抱歉,如果问题描述很糟糕。我想澄清一下

【问题讨论】:

    标签: json .net .net-core deserialization


    【解决方案1】:

    您的模型不能正确地代表您的 json。 positions 是一个数组数组,因此您的 Data 类应如下所示:

    public class Data
    {   
        public string[][] positions { get; set; }
    } 
    

    【讨论】:

      猜你喜欢
      • 2013-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多