fromJson static method
Returns a new MetricThreshold instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static MetricThreshold? 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(() {
assert(json.containsKey(r'level'),
'Required key "MetricThreshold[level]" is missing from JSON.');
assert(json[r'level'] != null,
'Required key "MetricThreshold[level]" has a null value in JSON.');
assert(json.containsKey(r'operator'),
'Required key "MetricThreshold[operator]" is missing from JSON.');
assert(json[r'operator'] != null,
'Required key "MetricThreshold[operator]" has a null value in JSON.');
assert(json.containsKey(r'value'),
'Required key "MetricThreshold[value]" is missing from JSON.');
assert(json[r'value'] != null,
'Required key "MetricThreshold[value]" has a null value in JSON.');
return true;
}());
return MetricThreshold(
level: mapValueOfType<String>(json, r'level')!,
operator_: mapValueOfType<String>(json, r'operator')!,
value: mapValueOfType<double>(json, r'value')!,
valueUnit: mapValueOfType<String>(json, r'value_unit'),
windowSeconds: mapValueOfType<int>(json, r'window_seconds'),
);
}
return null;
}