fromJson method

FieldMap<K, Object> fromJson(
  1. Map<String, Object?> json
)

Implementation

FieldMap<K, Object> fromJson(Map<String, Object?> json) {
  Map<K, Object> enumMap = EnumMapFactory<K>(fields).fromJson<Object>(json); // EnumMapFactory handles V type
  if (compareTypes(enumMap.values)) {
    return enumMap;
  } else {
    throw FormatException('Invalid JSON map for ${K.runtimeType}: $json - value types do not match expected types');
  }
  // per item message
  //  if (!key.isTypeOf(json[(key as Enum).name])) throw FormatException('$runtimeType: ${(key as Enum).name} is not of type ${key.type}');
}