Split items into separate objects

Describe the question/issue

Hi there!

I’ve received several json files with a list of many strings wherein the values need to be translated with the Deepl node to another language, and the output should be in json in the original format.

I have searched for a solution to split the lists of strings into separate objects so that the Deepl node can loop over the input, but no success.

I came accross the following topic which seemed to address exactly what I was looking for, but the code does not work anymore.

I’d appreciate any help in getting this fixed!

What is the error message (if any)?

The error I get when using the code supplied by the above mentioned topic is:

ReferenceError: `items` is not defined. Did you mean `$input.all()`?

Please share the workflow

In the workflow I have added a list of three as an example. I have 10 json files with around 200 lines each that need to be translated.

Share the output returned by the last node

Information on your n8n setup

  • **n8n version: 0.198.2
  • **Database you’re using (default: SQLite):
  • **Running n8n with the execution process [own(default), main]:
  • **Running n8n via [Docker, npm, n8n.cloud, desktop app]: Desktop app

You know when you tried so many things getting something to work, and eventually you decide to ask for help. And then, looking back at it, you try one thing and it works? Well, it’s solved by changing one simple thing that the error message literally suggests doing :stuck_out_tongue:

The code that works doing this:

const results = [];

for (const [key, value] of Object.entries($input.all()[0].json)) {
    name: key,
    value: value

return results;
1 Like

Hi @Backtrack, welcome to the community :tada:

Glad to hear you figured it out, thanks for sharing your solution! These variables were indeed changed recently. They are a better structured now I think, but the switch has definitely caused some confusion with older snippets. Sorry for the trouble.

1 Like

No problem, thank you for the reply @MutedJam!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.