fromJson static method
Returns a new IndexDetail instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static IndexDetail? 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 IndexDetail(
id: IndexDetailIdEnum.fromJson(json[r'id']),
name: mapValueOfType<String>(json, r'name'),
value: json[r'value'] == null
? null
: num.parse('${json[r'value']}'),
unit: IndexDetailUnitEnum.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']),
history: DaiPoint.listFromJson(json[r'history']),
);
}
return null;
}