Deserializing collections?

Jun 2, 2008 at 6:52 AM
Edited Jun 2, 2008 at 5:46 PM
Edit: I figured it out, for some reason intellisense wasnt showing me overloads or something

(collection_type)JavaScriptConvert.DeserializeObject(string_of_json, typeof(collection_type));
Jun 3, 2008 at 5:20 AM
Edited Jun 3, 2008 at 8:33 PM
nullsoldier wrote:
Edit: I figured it out, for some reason intellisense wasnt showing me overloads or something

(collection_type)JavaScriptConvert.DeserializeObject(string_of_json, typeof(collection_type));
I take back what I said. deserializing collections in this fashion does not work. I get the same exception as before. It tells me that there are, "too many elements in the sequence". I've seen it done before and this was the exact syntax that they used. Why does it work for one and not another?

            this.alerts = (List<Alert>)JavaScriptConvert.DeserializeObject(content, typeof(List<Alert>));

The declaration of this.alerts is public List<Alert> alerts. When I print out the value of content, it seems the value is escaped. Perhaps the problem could be because VS is automatically escaping it or something? This is just when I mouse over it.
"[{\"content\":\"Test Message\",\"icon\":1,\"actions\":null},{\"content\":\"Test Message\",\"icon\":1,\"actions\":null},{\"content\":\"Test Message\",\"icon\":1,\"actions\":null}]"

Coordinator
Jun 8, 2008 at 10:00 AM
Could you post the code for the Alert class, the JSON content you are deserializing and the exception stacktrace?