ArrowField.fromJson constructor
ArrowField.fromJson( - Map<String, Object?> json
)
Implementation
factory ArrowField.fromJson(Map<String, Object?> json) {
try {
final name = json['name'];
final dtype = json['dtype'] ?? json['type'];
if (name is! String || dtype is! Map) {
throw const FormatException('Invalid Arrow field');
}
final nullable = json['nullable'];
if (nullable != null || json.containsKey('nullable')) {
if (nullable is! bool) {
throw const FormatException('field.nullable must be a boolean');
}
}
return ArrowField(
name,
ArrowDataType.fromJson(_stringObjectMap(dtype, 'field.dtype')),
nullable: nullable as bool? ?? true,
allowEmptyName: true,
metadata: _metadataFromJson(
json['metadata'],
'field.metadata',
present: json.containsKey('metadata'),
),
);
} on FormatException {
rethrow;
} on ArgumentError catch (error) {
throw FormatException('Invalid Arrow field: $error');
} on TypeError catch (error) {
throw FormatException('Invalid Arrow field shape: $error');
}
}