Fix rational list not converted from/to json correctly

This commit is contained in:
Ming Ming 2021-04-10 20:10:46 +08:00
parent 8d2024c334
commit 4a8784f508

View file

@ -17,8 +17,14 @@ class Exif {
jsonValue = base64UrlEncode(value); jsonValue = base64UrlEncode(value);
} else if (value is Rational) { } else if (value is Rational) {
jsonValue = value.toJson(); jsonValue = value.toJson();
} else if (value is List<Rational>) { } else if (value is List) {
jsonValue = value.map((e) => e.toJson()).toList(); jsonValue = value.map((e) {
if (e is Rational) {
return e.toJson();
} else {
return e;
}
}).toList();
} else { } else {
jsonValue = value; jsonValue = value;
} }
@ -33,10 +39,14 @@ class Exif {
exifValue = base64Decode(value); exifValue = base64Decode(value);
} else if (value is Map) { } else if (value is Map) {
exifValue = Rational.fromJson(value.cast<String, dynamic>()); exifValue = Rational.fromJson(value.cast<String, dynamic>());
} else if (value is List<Map>) { } else if (value is List) {
exifValue = value exifValue = value.map((e) {
.map((e) => Rational.fromJson(e.cast<String, dynamic>())) if (e is Map) {
.toList(); return Rational.fromJson(e.cast<String, dynamic>());
} else {
return value;
}
}).toList();
} else { } else {
exifValue = value; exifValue = value;
} }