fromJson static method
Returns a new OfferValue from a decoded JSON object, or null for something that is not an object. Throws a FormatException when no variant fits: skipping it would hide a purchase or a price.
Implementation
static OfferValue? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
switch (json[r'type']) {
case "fixed":
final variant = FixedValue.fromJson(json);
return variant == null ? null : OfferValue(variant);
case "range":
final variant = ValueRange.fromJson(json);
return variant == null ? null : OfferValue(variant);
}
throw FormatException('Unknown type ${json[r'type']} in OfferValue');
}
return null;
}