JsonSerializationException

260*_*986 1 c# json.net json-deserialization

json喜欢这个(删除它的一部分因为它不是问题)

   {
   "obj" : {
      "id" : "a18",
      "param" : {
         "system" : 0,
         "member_fill" : "0",
         "name" : "MainAnketa",
         "multi" : 0
      }
   }
}
Run Code Online (Sandbox Code Playgroud)

我尝试在Newton.Json的帮助下将其反序列化为以下对象:

public class GetMainAnketaResponse
    {
        [JsonProperty(PropertyName = "obj")] public Anketa AnketaData;

        public class Anketa
        {
            [JsonProperty(PropertyName = "order")]
            public List<string> FieldsOrder;

            [JsonProperty(PropertyName = "id")]
            public string Id;

            [JsonProperty(PropertyName = "param")]
            public List<Parameter> Parameters;

            public class Parameter
            {
                [JsonProperty(PropertyName = "system")]
                public int System;

                [JsonProperty(PropertyName = "member_fill")]
                public string MemberFill;

                [JsonProperty(PropertyName = "name")]
                public string Name;

                [JsonProperty(PropertyName = "multi")]
                public int Multi;
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

但收到此错误:

无法将当前JSON对象(例如{"name":"value"})反序列化为类型'System.Collections.Generic.List`1 [SubscribeProLib.GetMainAnketaResponse + Anketa + Parameter]',因为该类型需要JSON数组(例如[ 1,2,3])正确反序列化.要修复此错误,请将JSON更改为JSON数组(例如[1,2,3])或更改反序列化类型,使其成为普通的.NET类型(例如,不是像整数这样的基本类型,而不是类似的集合类型可以从JSON对象反序列化的数组或List.JsonObjectAttribute也可以添加到类型中以强制它从JSON对象反序列化.Path'obj.param.system',第61行,第20位.

System属性有什么问题?

And*_*kin 5

你有一个List参数,但你的JSON只有一个对象"param".