mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
make csv imports try to parse values to json (#7820)
This commit is contained in:
@@ -104,8 +104,16 @@ export class ImportService {
|
||||
.pipe(csv())
|
||||
.on('data', (value: Record<string, string>) => {
|
||||
const obj = transform(value, (result: Record<string, string>, value, key) => {
|
||||
if (value.length === 0) delete result[key];
|
||||
else set(result, key, value);
|
||||
if (value.length === 0) {
|
||||
delete result[key];
|
||||
} else {
|
||||
try {
|
||||
const parsedJson = JSON.parse(value);
|
||||
set(result, key, parsedJson);
|
||||
} catch {
|
||||
set(result, key, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
saveQueue.push(obj);
|
||||
|
||||
Reference in New Issue
Block a user