Reputation: 34421
I have a class looking like this:
class MyClass {
public int Id;
public Dictionary<int, MyClass[]> ChildValues;
}
when I try to deserialize this class using Json.NET:
MyClass x = return JsonConvert.DeserializeObject<MyClass>(s);
I receive the error Expected a JsonObjectContract or JsonDictionaryContract for type 'System.Collections.Generic.Dictionary`2[System.Int32,MyClass[]]', got 'Newtonsoft.Json.Serialization.JsonDictionaryContract'.
What does this error message mean and how can I resolve it?
Upvotes: 1
Views: 1423
Reputation: 34421
I found it. The problem was that the Json from the client was an array and not a dictionary (which in turn was because the script file was cached by IE).
Upvotes: 1