asNum method
Implementation
num asNum(String key) {
final value = this[key];
if (value == null) {
return 0;
}
if (value is int) {
return value;
}
if (value is double) {
return value;
}
try {
if (value is String) {
if (value.contains('.')) {
return double.parse(value);
} else {
return int.parse(value);
}
}
} catch (e) {
_print('json 解析异常,异常值:"$key":$value');
}
return 0;
}