Derek
Derek

Reputation: 8630

Json Deserialise Issue

When attempting to Deserialize this property in my class im getting the following error message :-

Error reading string. Unexpected token: StartArray. Path '['When opening the account which of these applied?']', line 53, position 58.

JSON Snippet

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

The C# Property :-

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

Its the only property that throws an errors.

Im Deserialising using the following statement :--

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

Any Ideas as to why its doing this?

Upvotes: 1

Views: 252

Answers (1)

Volkan Paksoy
Volkan Paksoy

Reputation: 6937

It's not a single item but an array. If you update your class as below it should work:

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

Upvotes: 3

Related Questions