RecommendSpecResponse.fromJson constructor

RecommendSpecResponse.fromJson(
  1. Object? j
)

Implementation

factory RecommendSpecResponse.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return RecommendSpecResponse(
    baseModel: switch (json['baseModel']) {
      null => '',
      Object $1 => decodeString($1),
    },
    recommendations: switch (json['recommendations']) {
      null => [],
      List<Object?> $1 => [
        for (final i in $1) RecommendSpecResponse_Recommendation.fromJson(i),
      ],
      _ => throw const FormatException('"recommendations" is not a list'),
    },
    specs: switch (json['specs']) {
      null => [],
      List<Object?> $1 => [
        for (final i in $1)
          RecommendSpecResponse_MachineAndModelContainerSpec.fromJson(i),
      ],
      _ => throw const FormatException('"specs" is not a list'),
    },
  );
}