Translate JSON file with Deepl

Yes, when you extract (JSON) data from a binary file, n8n groups your JSON as a collection of properties named after the given output field (“data” is default).

For your purpose, you want to flatten this structure (meaning: get rid of “data”), as you don’t want this additional hierarchy in your final output. You can easily achieve this by adding .data in the first line of code (I am referring to the code node in the original workflow which I posted). This way, you access only the JSON that is within (or “beneath”) the data property, if that makes sense.

// Get original structure and translated content
const original = $('Extract from File').all()[0].json.data;
const translated = $input.all()[0].json;

I hope, this helps. Cheers, Ingo

1 Like