Json反序列化问题
Json Deserialise Issue
在我的 class 中尝试反序列化此 属性 时,我收到以下错误消息:-
Error reading string. Unexpected token: StartArray. Path '['When
opening the account which of these applied?']', line 53, position 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);
关于它为什么这样做有什么想法吗?
不是单项而是数组。如果您按如下方式更新 class,它应该可以工作:
[JsonProperty(PropertyName = "When opening the account which of these applied?")]
public List<string> Whenopeningtheaccountwhichoftheseapplied { get; set; }
在我的 class 中尝试反序列化此 属性 时,我收到以下错误消息:-
Error reading string. Unexpected token: StartArray. Path '['When opening the account which of these applied?']', line 53, position 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);
关于它为什么这样做有什么想法吗?
不是单项而是数组。如果您按如下方式更新 class,它应该可以工作:
[JsonProperty(PropertyName = "When opening the account which of these applied?")]
public List<string> Whenopeningtheaccountwhichoftheseapplied { get; set; }