fromJson static method

TranscriptionSettingsResponse? fromJson(
  1. dynamic value
)

Returns a new TranscriptionSettingsResponse instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static TranscriptionSettingsResponse? 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(() {
      assert(json.containsKey(r'closed_caption_mode'),
          'Required key "TranscriptionSettingsResponse[closed_caption_mode]" is missing from JSON.');
      assert(json[r'closed_caption_mode'] != null,
          'Required key "TranscriptionSettingsResponse[closed_caption_mode]" has a null value in JSON.');
      assert(json.containsKey(r'language'),
          'Required key "TranscriptionSettingsResponse[language]" is missing from JSON.');
      assert(json[r'language'] != null,
          'Required key "TranscriptionSettingsResponse[language]" has a null value in JSON.');
      assert(json.containsKey(r'mode'),
          'Required key "TranscriptionSettingsResponse[mode]" is missing from JSON.');
      assert(json[r'mode'] != null,
          'Required key "TranscriptionSettingsResponse[mode]" has a null value in JSON.');
      return true;
    }());

    return TranscriptionSettingsResponse(
      closedCaptionMode:
          TranscriptionSettingsResponseClosedCaptionModeEnum.fromJson(
              json[r'closed_caption_mode'])!,
      //MANUAL_EDIT: default value added since sometimes language came as an empty string
      language: TranscriptionSettingsResponseLanguageEnum.fromJson(
              json[r'language']) ??
          TranscriptionSettingsResponseLanguageEnum.auto,
      mode: TranscriptionSettingsResponseModeEnum.fromJson(json[r'mode'])!,
      speechSegmentConfig:
          SpeechSegmentConfig.fromJson(json[r'speech_segment_config']),
      translation: TranslationSettings.fromJson(json[r'translation']),
    );
  }
  return null;
}