fromJson static method
Returns a new ReferenceAnswer instance and imports its values from
value if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static ReferenceAnswer? 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(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "ReferenceAnswer[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "ReferenceAnswer[$key]" has a null value in JSON.');
});
return true;
}());
return ReferenceAnswer(
age: mapValueOfType<String>(json, r'age'),
asOf: mapValueOfType<String>(json, r'asOf'),
from: mapValueOfType<String>(json, r'from'),
hit: mapValueOfType<bool>(json, r'hit'),
key: mapValueOfType<String>(json, r'key'),
matched: mapValueOfType<String>(json, r'matched'),
refusal: mapValueOfType<String>(json, r'refusal'),
score: num.parse('${json[r'score']}'),
set_: mapValueOfType<String>(json, r'set'),
stale: mapValueOfType<bool>(json, r'stale'),
value: mapCastOfType<String, String>(json, r'value') ?? const {},
verdict: mapValueOfType<String>(json, r'verdict'),
version: mapValueOfType<String>(json, r'version'),
);
}
return null;
}