ZipOptions.fromJson constructor
ZipOptions.fromJson(
- Object? json_
Returns a new instance from a JSON value. May throw if the value does not have the expected structure.
Implementation
factory ZipOptions.fromJson(Object? json_) {
final json = json_ is Map
? _spec.fields.map((f) => json_[f.label]).toList(growable: false)
: json_;
return switch (json) {
[
final compressionMethod,
final compressionLevel,
final lastModifiedTime,
final permissions,
final comment,
] ||
(
final compressionMethod,
final compressionLevel,
final lastModifiedTime,
final permissions,
final comment,
) => ZipOptions(
compressionMethod: ZipCompressionMethod.fromJson(compressionMethod),
compressionLevel: Option.fromJson(
compressionLevel,
(some) => some! as int,
).value,
lastModifiedTime: Option.fromJson(
lastModifiedTime,
(some) => bigIntFromJson(some),
).value,
permissions: Option.fromJson(permissions, (some) => some! as int).value,
comment: Option.fromJson(
comment,
(some) => BytesOrUnicode.fromJson(some),
).value,
),
_ => throw Exception('Invalid JSON $json_'),
};
}