If I deserialize some JSON to a dictionary of objects like so:
var properties = "{\"property1\":\"\",\"property2\":2}";
var dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(properties);
Console.WriteLine(dictionary["property2"].GetType()); // Prints System.Int64
The integer-valued property property2
is getting automatically deserialized as a long
and not an int
.
Can I convert automatically to int
?