fromJson static method
Implementation
static VariantCodecInterface fromJson(final Map<String, dynamic> json) {
if (json['type'] == null || json['id'] == null) {
throw Exception('Exception as didn\'t found the type for this json: $json');
}
final int id = json['id'];
final Map<String, dynamic> typeObject = json['type'];
final MapEntry defType = (typeObject['def'] as Map).entries.first;
final List<Variants> variants = <Variants>[];
if (defType.value['variants'] != null) {
for (final variant in defType.value['variants']) {
variants.add(Variants.fromJson(variant));
}
}
return VariantCodecInterface(
id: id,
variants: variants,
params: typeObject['params']?.map((final e) => Params.fromJson(e))?.toList()?.cast<Params>(),
path: typeObject['path']?.cast<String>(),
docs: typeObject['docs']?.cast<String>(),
);
}