Is there any way to get the name of a key from its value?

Hey!
I have a key value in the input, but its name is not known.

You can do something like this:

const searchValue = 'value2';

let foundColum = '';
items.forEach(item => {
  foundColum = '';
  for (const key in item.json) {
    if (item.json[key] === searchValue) {
      foundColum = key;
      break;
    }
  }
  item.json.foundColum = foundColum;
});

return items;

Here an example workflow:

Thanks Jan!

Is there a way to do the opposite of this, we know the Key/Column name but want to pull back the value from deeply nested results.

1 Like