mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
⚡ Make JSON.parse of data in MoveBinaryData optional
This commit is contained in:
@@ -170,6 +170,23 @@ export class MoveBinaryData implements INodeType {
|
||||
default: false,
|
||||
description: 'If the source key should be kept. By default does it get deleted.',
|
||||
},
|
||||
{
|
||||
displayName: 'JSON Parse',
|
||||
name: 'jsonParse',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/mode': [
|
||||
'binaryToJson',
|
||||
],
|
||||
'/setAllData': [
|
||||
false
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Run JSON parse on the data to get propery object data.',
|
||||
},
|
||||
{
|
||||
displayName: 'Mime Type',
|
||||
name: 'mimeType',
|
||||
@@ -235,15 +252,19 @@ export class MoveBinaryData implements INodeType {
|
||||
continue;
|
||||
}
|
||||
|
||||
const convertedValue = JSON.parse(new Buffer(value.data, 'base64').toString('ascii'));
|
||||
let convertedValue = new Buffer(value.data, 'base64').toString('utf8');
|
||||
|
||||
if (setAllData === true) {
|
||||
// Set the full data
|
||||
newItem.json = convertedValue;
|
||||
newItem.json = JSON.parse(convertedValue);
|
||||
} else {
|
||||
// Does get added to existing data so copy it first
|
||||
newItem.json = JSON.parse(JSON.stringify(item.json));
|
||||
|
||||
if (options.jsonParse) {
|
||||
convertedValue = JSON.parse(convertedValue);
|
||||
}
|
||||
|
||||
const destinationKey = this.getNodeParameter('destinationKey', itemIndex, '') as string;
|
||||
set(newItem.json, destinationKey, convertedValue);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user