How can map the array of input items and also keep the required json format

I have an array of items with detail information which i want to map it into the json accordingly, i need it to be dynamic as the input number of items can be vary, how can i key the expression so that every item will be input to the json while the format remains

Information on your n8n setup

  • n8n version: cloud

I tried suggestion from chatgpt, but it shows object object

Hi @Kent_Lee,

For any complex data mapping it is almost always best to just use some custom javascript code in a Code Node. Have a look at the below example and let me know if I need to explain anything about it. I hope this resolves your issue: