Help in reformatting json

Describe the issue/error/question

Dear n8n community

I’ve tried lists, javascript and even set to achieve this without success. Any help would be incredibly appreciated!

Here is an image describing the essence of what i am trying to achieve

Essentially it is to transform the “attributes” into a flat list rather than nested.

I feel like I’m probably making some rookie mistake here - but any help would be greatly appreciated!

Hi @pmg, welcome to the community :tada:

Such “value of object to key” transformations are a bit hard to achieve because the mapping here is custom, so right now there is no pre-built node for this.

However, if you are okay with using JavaScript, something like this should do the job:

This would return a single “attributes” array with key/item pairs such as "neutered": false:

Is this what you had in mind? :slight_smile:

Going forward it’d be great if you could paste your existing JSON data as text rather than take a screenshot. This will make it much easier for other users to reproduce the data structure (and help) without having to type it themselves.