Created
January 17, 2018 19:38
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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