fromJson static method

CommitChunkedUploadResponse? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static CommitChunkedUploadResponse? 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'success'), 'Required key "CommitChunkedUploadResponse[success]" is missing from JSON.');
      assert(json[r'success'] != null, 'Required key "CommitChunkedUploadResponse[success]" has a null value in JSON.');
      assert(json.containsKey(r'fileId'), 'Required key "CommitChunkedUploadResponse[fileId]" is missing from JSON.');
      assert(json[r'fileId'] != null, 'Required key "CommitChunkedUploadResponse[fileId]" has a null value in JSON.');
      assert(json.containsKey(r'manifestId'), 'Required key "CommitChunkedUploadResponse[manifestId]" is missing from JSON.');
      assert(json[r'manifestId'] != null, 'Required key "CommitChunkedUploadResponse[manifestId]" has a null value in JSON.');
      assert(json.containsKey(r'version'), 'Required key "CommitChunkedUploadResponse[version]" is missing from JSON.');
      assert(json[r'version'] != null, 'Required key "CommitChunkedUploadResponse[version]" has a null value in JSON.');
      assert(json.containsKey(r'totalSize'), 'Required key "CommitChunkedUploadResponse[totalSize]" is missing from JSON.');
      assert(json[r'totalSize'] != null, 'Required key "CommitChunkedUploadResponse[totalSize]" has a null value in JSON.');
      return true;
    }());

    return CommitChunkedUploadResponse(
      success: mapValueOfType<bool>(json, r'success')!,
      fileId: mapValueOfType<String>(json, r'fileId')!,
      manifestId: mapValueOfType<String>(json, r'manifestId')!,
      version: mapValueOfType<int>(json, r'version')!,
      totalSize: mapValueOfType<int>(json, r'totalSize')!,
      physicalSize: mapValueOfType<int>(json, r'physicalSize'),
      deduplicationPct: mapValueOfType<double>(json, r'deduplicationPct'),
      totalBlocks: mapValueOfType<int>(json, r'totalBlocks'),
      newBlocks: mapValueOfType<int>(json, r'newBlocks'),
      deduplicatedBlocks: mapValueOfType<int>(json, r'deduplicatedBlocks'),
    );
  }
  return null;
}