fromJson static method
Index?
fromJson(
- dynamic value
)
Returns a new Index instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Index? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
return true;
}());
return Index(
id: IndexIdEnum.fromJson(json[r'id']),
name: mapValueOfType<String>(json, r'name'),
value: json[r'value'] == null
? null
: num.parse('${json[r'value']}'),
unit: IndexUnitEnum.fromJson(json[r'unit']),
measured: mapValueOfType<bool>(json, r'measured'),
source_: mapValueOfType<String>(json, r'source'),
historyAvailable: mapValueOfType<bool>(json, r'history_available'),
asOf: mapValueOfType<String>(json, r'as_of'),
note: mapValueOfType<String>(json, r'note'),
recentHistory: DaiPoint.listFromJson(json[r'recent_history']),
);
}
return null;
}