前言
有一个JSON数据,其中某个字段的值会传递整型和浮点型两种类型的值(实际上都是浮点型,只不过浮点型数据以.0结尾会被省略,导致看起来是一个整型数据)
此时如果为这个字段定义为int类型,那么会报错:Unhandled Exception: type 'double' is not a subtype of type 'int'
此时如果为这个字段定义为double类型,那么会报错:Unhandled Exception: type 'int' is not a subtype of type 'double'
解决问题
完成
参考文献
Stackoom——Nagual