fromJson static method

CallClosedCaption? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static CallClosedCaption? 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'end_time'),
          'Required key "CallClosedCaption[end_time]" is missing from JSON.');
      assert(json[r'end_time'] != null,
          'Required key "CallClosedCaption[end_time]" has a null value in JSON.');
      assert(json.containsKey(r'id'),
          'Required key "CallClosedCaption[id]" is missing from JSON.');
      assert(json[r'id'] != null,
          'Required key "CallClosedCaption[id]" has a null value in JSON.');
      assert(json.containsKey(r'language'),
          'Required key "CallClosedCaption[language]" is missing from JSON.');
      assert(json[r'language'] != null,
          'Required key "CallClosedCaption[language]" has a null value in JSON.');
      assert(json.containsKey(r'speaker_id'),
          'Required key "CallClosedCaption[speaker_id]" is missing from JSON.');
      assert(json[r'speaker_id'] != null,
          'Required key "CallClosedCaption[speaker_id]" has a null value in JSON.');
      assert(json.containsKey(r'start_time'),
          'Required key "CallClosedCaption[start_time]" is missing from JSON.');
      assert(json[r'start_time'] != null,
          'Required key "CallClosedCaption[start_time]" has a null value in JSON.');
      assert(json.containsKey(r'text'),
          'Required key "CallClosedCaption[text]" is missing from JSON.');
      assert(json[r'text'] != null,
          'Required key "CallClosedCaption[text]" has a null value in JSON.');
      assert(json.containsKey(r'translated'),
          'Required key "CallClosedCaption[translated]" is missing from JSON.');
      assert(json[r'translated'] != null,
          'Required key "CallClosedCaption[translated]" has a null value in JSON.');
      assert(json.containsKey(r'user'),
          'Required key "CallClosedCaption[user]" is missing from JSON.');
      assert(json[r'user'] != null,
          'Required key "CallClosedCaption[user]" has a null value in JSON.');
      return true;
    }());

    return CallClosedCaption(
      endTime: mapDateTime(json, r'end_time', r'')!,
      id: mapValueOfType<String>(json, r'id')!,
      language: mapValueOfType<String>(json, r'language')!,
      service: mapValueOfType<String>(json, r'service'),
      speakerId: mapValueOfType<String>(json, r'speaker_id')!,
      startTime: mapDateTime(json, r'start_time', r'')!,
      text: mapValueOfType<String>(json, r'text')!,
      translated: mapValueOfType<bool>(json, r'translated')!,
      user: UserResponse.fromJson(json[r'user'])!,
    );
  }
  return null;
}