In the code below I am receiving the error:
{"Unable to cast object of type 'System.Int64' to type 'System.Int32'."}
Here is the code:
var dic = new Dictionary<string, object>() { { "value", 100 } };
var json = JsonConvert.SerializeObject(dic);
dic = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);
int value = (int)dic["value"];//throws error here
Any ideas why this should happen? How can i avoid the error?
The dictionary contains other types too which have been omitted.