Json Deserialise问题

时间:2015-10-01 10:40:08

标签: c# json json.net deserialization

尝试在我的类中反序列化此属性时收到以下错误消息: -

  

读取字符串时出错。意外的令牌:StartArray。路径' ['何时   打开这些应用的帐户?']',第53行,第58位。

JSON代码段

"When opening the account which of these applied?": [
            "option1",
            "option2",
            "option3",
            "option4"
        ]

C#属性: -

[JsonProperty(PropertyName = "When opening the account which of these applied?")]
public string Whenopeningtheaccountwhichoftheseapplied { get; set; }

它是唯一抛出错误的属性。

使用以下语句进行反序列化: -

var submission = JsonConvert.DeserializeObject<FormStackSubmission>(json);

关于为什么要这样做的任何想法?

1 个答案:

答案 0 :(得分:3)

它不是单个项目,而是数组。如果您按照以下更新课程,则应该有效:

[JsonProperty(PropertyName = "When opening the account which of these applied?")]
public List<string> Whenopeningtheaccountwhichoftheseapplied { get; set; }