decodeJsonTree method
Converts json
(any JSON tree) to an instance of T
.
Throws ArgumentError if the JSON does not match.
Implementation
@override
double decodeJsonTree(Object? json) {
if (json is num) {
final doubleValue = json.toDouble();
if (doubleValue == -0.0 && !negativeZeroes) {
return 0.0;
}
return doubleValue;
}
if (json is String) {
switch (json) {
case 'NaN':
return double.nan;
case 'Infinity':
return double.infinity;
case '-Infinity':
return double.negativeInfinity;
}
}
throw JsonDecodingError.expectedNumberOrString(json);
}