小编joh*_*ohn的帖子

JSON反序列化-int自动转换为long

如果我将一些 JSON 反序列化为对象字典,如下所示:

var properties = "{\"property1\":\"\",\"property2\":2}";

var dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(properties);

Console.WriteLine(dictionary["property2"].GetType()); // Prints System.Int64
Run Code Online (Sandbox Code Playgroud)

整数值属性property2会自动反序列化为 along而不是int

我可以自动转换为 吗int

c# json json.net

5
推荐指数
0
解决办法
2653
查看次数

标签 统计

c# ×1

json ×1

json.net ×1