mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
⚡ Make JSON.parse of data in MoveBinaryData optional
This commit is contained in:
parent
7ebe09cec1
commit
b16b664afa
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue