How to single item to multiple items

Hi there,
I went through this forum already, tried all the tips, but I am still not able to solve this:

a result of an http node is a single item ““colors””, I need to split this into multiple items, so I can iterate over blue, red…

[
  { 
    "colors": [
    {
       "id":  1,
       "name": "blue"
    },
    {
       "id":  2,
       "name": "red"
    }
    ]
  }
]
{
  "nodes": [
    {
      "parameters": {
        "functionCode": "const data = items[0].json;\nconst data_arr = Object.keys(data[0]).map(key => {\n    return data[0][key]\n})\n\nreturn [{json:data_arr}]"
      },
      "name": "Create array",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        70,
        1050
      ]
    },
    {
      "parameters": {
        "functionCode": "items[0].json = \n{\n        \"color\": [\n        {\n            \"id\": 1,\n            \"name\": \"blue\",\n        },\n        {\n            \"id\": 2,\n            \"name\": \"red\",\n        }\n]\n};\nreturn items;"
      },
      "name": "Create Data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        -110,
        1050
      ]
    }
  ],
  "connections": {
    "Create Data": {
      "main": [
        [
          {
            "node": "Create array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

this is what I tried. But I got error in second node:
““Cannot convert undefined or null to object””

Welcome to the community @stollz!

You can adapt what is documented here:

return items[0].json.color.map(item => {
  return {
    json: item
  }
});

Thanks @jan here is the solution:
( I needed to add the color ```
const data = items[0].json[“color”];



    {
      "nodes": [
    {
      "parameters": {
        "functionCode": "return items[0].json.map(item => { \n  return {\n    json: item,\n  }\n})"
      },
      "name": "Create JSON-items",
      "type": "n8n-nodes-base.function",
      "position": [
        250,
        1050
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "functionCode": "const data = items[0].json[\"color\"];\nconst data_arr = Object.keys(data).map(key => {\n    return data[key]\n})\n\nreturn [{json:data_arr}]"
      },
      "name": "Create array",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        70,
        1050
      ]
    },
    {
      "parameters": {
        "functionCode": "items[0].json = \n{\n        \"color\": [\n        {\n            \"id\": 1,\n            \"name\": \"blue\",\n        },\n        {\n            \"id\": 2,\n            \"name\": \"red\",\n        }\n]\n};\nreturn items;"
      },
      "name": "Create Data",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        -110,
        1050
      ]
    }
      ],
      "connections": {
    "Create array": {
      "main": [
        [
          {
            "node": "Create JSON-items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Data": {
      "main": [
        [
          {
            "node": "Create array",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
      }
    }

Would still suggest to use the solution I did post as it is simpler, does everything in one step and does not produce an invalid state inbetween with the data being an array.

you are right, I removed the step in the middle. Less nodes, same result. Thank you very much @jan