extractBaseObject static method
Extracts the base object for model generation. If the input is a list, returns the first element if available.
Implementation
static Map<String, dynamic> extractBaseObject(dynamic json) {
if (json is Map<String, dynamic>) {
return json;
} else if (json is List && json.isNotEmpty) {
final first = json.first;
if (first is Map<String, dynamic>) {
return first;
}
}
throw Exception('JSON does not contain a valid object for model generation.');
}