handling for 'cat' model key

This commit is contained in:
ggurdin 2024-11-01 15:23:06 -04:00
parent da6d64972b
commit 00cb1f1c75
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
2 changed files with 9 additions and 4 deletions

View file

@ -108,7 +108,7 @@ class OneConstructUse {
: null;
debugger(when: kDebugMode && constructType == null);
final categoryEntry = json['categories'];
final categoryEntry = json['cat'] ?? json['categories'];
String? category;
if (categoryEntry != null) {
if ((categoryEntry is List) && categoryEntry.isNotEmpty) {

View file

@ -21,10 +21,14 @@ class ConstructIdentifier {
});
factory ConstructIdentifier.fromJson(Map<String, dynamic> json) {
final categoryEntry = json['cat'];
final categoryEntry = json['cat'] ?? json['categories'];
String? category;
if (categoryEntry != null && categoryEntry is String) {
category = categoryEntry;
if (categoryEntry != null) {
if (categoryEntry is String) {
category = categoryEntry;
} else if (categoryEntry is List) {
category = categoryEntry.first;
}
}
try {
@ -46,6 +50,7 @@ class ConstructIdentifier {
return {
'lemma': lemma,
'type': type.string,
'cat': category,
};
}