Skip to content

Instantly share code, notes, and snippets.

@willismonroe
Created January 17, 2018 19:38
Show Gist options
  • Save willismonroe/933c514f26d6e26a3d03e8728593a977 to your computer and use it in GitHub Desktop.
Save willismonroe/933c514f26d6e26a3d03e8728593a977 to your computer and use it in GitHub Desktop.
Reading zip archive, extracting one file, decoding JSON and printing list of keys.
import 'dart:io';
import 'dart:convert';
import 'package:archive/archive.dart';
void main() {
List<int> bytes = new File('saao-saa08.zip').readAsBytesSync();
Archive archive = new ZipDecoder().decodeBytes(bytes);
Utf8Decoder decoder = new Utf8Decoder();
Map catalog;
for (ArchiveFile file in archive) {
String name = file.name;
print(name);
if (name == 'saao/saa08/catalogue.json') {
String contents = decoder.convert(file.content);
print(contents);
catalog = JSON.decode(contents);
}
}
print(catalog["members"].keys.toList());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment