fromJson static method
Decodes an already-parsed keys.json.
directory is what file will resolve shots against; the default only
suits a caller that will not open one.
Implementation
static TranslationExport fromJson(
Map<String, Object?> json, {
String directory = '.',
}) {
var version = _int(json['version']);
if (version > translationExportVersion) {
throw FormatException(
'This export is version $version and this is a reader for '
'$translationExportVersion. Upgrade the flutterware dependency of '
'whatever reads it.',
);
}
return TranslationExport(
version: version,
directory: directory,
catalogs: _list(json['catalogs'], ExportedCatalog.fromJson),
keys: _list(json['keys'], ExportedKey.fromJson),
findings: switch (json['findings']) {
Map findings => ExportFindings.fromJson(
findings.cast<String, Object?>(),
),
_ => const ExportFindings(),
},
measuredMaxLengths: json['maxLengths'] is Map,
maxLengthDevices: switch (json['maxLengths']) {
Map block => [
for (var device in block['devices'] as List? ?? const [])
if (device is String) device,
],
_ => const [],
},
);
}