How could I create object from array?

Hi, I use function node to create this object from this array:

My array:

[
"text 1",
"text 2",
"text 3"
]

My object I want to return:

return [
  {
    json: {
      message: "text 1"
    } 
  },
  {
    json: {
      message: "text 2"
    }
  },
  {
    json: {
      message: "text 3"
    }
  }
]

Assuming that the data is saved in the property “data” you can do the following in a Function-Node:

return items[0].json.data.map(message => {
  return {
    json: {
      message
    },
  }
});

Here an example workflow:

3 Likes

Yeah, map is solution
Thank you very much