Extracting only some data from array

I have the following data and need some help extracting the first part of the array


The json coming out of the merge tag looks like this

[
  {
    "due_date": null,
    "due_date_reason": "",
    "due_date_status": "not_set",
    "total_comments": 0,
    "tags": [
      [
        "rent",
        "#5551D3"
      ],
      [
        "existing listing",
        "#5178D3"
      ]
    ],
    "attachments": [],
    "status": 79,
    "status_extra_info": {
      "name": "Pending",
      "color": "#70728F",
      "is_closed": false
    },
    "assigned_to": null,
    "assigned_to_extra_info": null,
    "owner": 19,
    "milestone": null,
    "milestone_slug": null,
    "milestone_name": null,
    "is_closed": false,
    "points": {},
    "backlog_order": 1652854497914106,
    "sprint_order": 1652854497914152,
    "kanban_order": 1652854497933623,
    "created_date": "2022-05-18T06:14:57.933Z",
    "modified_date": "2022-06-15T06:26:23.807Z",
    "finish_date": null,
    "subject": "RENT | 109521 | test ID 1505 | ",
    "client_requirement": false,
    "team_requirement": false,
    "generated_from_issue": null,
    "generated_from_task": null,
    "from_task_ref": null,
    "external_reference": null,
    "tribe_gig": null,
    "version": 8,
    "watchers": [],
    "is_blocked": false,
    "blocked_note": "",
    "total_points": null,
    "comment": "",
    "origin_issue": null,
    "origin_task": null,
    "epics": null,
    "epic_order": null,
    "tasks": [],
    "total_attachments": 0,
    "swimlane": null,
    "assigned_users": [],
    "existingTags": [
      [
        "rent",
        "#5551D3"
      ],
      [
        "existing listing",
        "#5178D3"
      ]
    ],
    "checkID": 109521
  },
  {
    "due_date": null,
    "due_date_reason": "",
    "due_date_status": "not_set",
    "total_comments": 0,
    "tags": [
      [
        "rent",
        "#5551D3"
      ],
      [
        "existing listing",
        "#5178D3"
      ]
    ],
    "attachments": [],
    "status": 79,
    "status_extra_info": {
      "name": "Pending",
      "color": "#70728F",
      "is_closed": false
    },
    "assigned_to": null,
    "assigned_to_extra_info": null,
    "owner": 19,
    "milestone": null,
    "milestone_slug": null,
    "milestone_name": null,
    "is_closed": false,
    "points": {},
    "backlog_order": 1654311239349254,
    "sprint_order": 1654311239349285,
    "kanban_order": 1655270298421891,
    "created_date": "2022-06-04T02:53:59.365Z",
    "modified_date": "2022-06-15T08:40:57.648Z",
    "finish_date": null,
    "subject": "RENT | 148901 | Amazing 4 bedroom villa with ocean views MONTHLY |",
    "client_requirement": false,
    "team_requirement": false,
    "generated_from_issue": null,
    "generated_from_task": null,
    "from_task_ref": null,
    "external_reference": null,
    "tribe_gig": null,
    "version": 15,
    "watchers": [],
    "is_blocked": false,
    "blocked_note": "",
    "total_points": null,
    "comment": "",
    "origin_issue": null,
    "origin_task": null,
    "epics": null,
    "epic_order": null,
    "tasks": [],
    "total_attachments": 0,
    "swimlane": null,
    "assigned_users": [],
    "existingTags": [
      [
        "rent",
        "#5551D3"
      ],
      [
        "existing listing",
        "#5178D3"
      ]
    ],
    "checkID": 148901
  },
  {
    "due_date": null,
    "due_date_reason": "",
    "due_date_status": "not_set",
    "total_comments": 0,
    "tags": [
      [
        "rent",
        "#5551D3"
      ],
      [
        "existing listing",
        "#5178D3"
      ]
    ],
    "attachments": [],
    "status": 81,
    "status_extra_info": {
      "name": "Issue",
      "color": "#E47C40",
      "is_closed": false
    },
    "assigned_to": null,
    "assigned_to_extra_info": null,
    "owner": 19,
    "milestone": null,
    "milestone_slug": null,
    "milestone_name": null,
    "is_closed": false,
    "points": {},
    "backlog_order": 1652855709196144,
    "sprint_order": 1652855709196221,
    "kanban_order": 2,
    "created_date": "2022-05-18T06:35:09.214Z",
    "modified_date": "2022-05-18T06:38:11.543Z",
    "finish_date": null,
    "subject": "RENT | 11650 | 5 Bedroom Villa in Ungasan (of8f465) | ",
    "client_requirement": false,
    "team_requirement": false,
    "generated_from_issue": null,
    "generated_from_task": null,
    "from_task_ref": null,
    "external_reference": null,
    "tribe_gig": null,
    "version": 2,
    "watchers": [],
    "is_blocked": false,
    "blocked_note": "",
    "total_points": null,
    "comment": "",
    "origin_issue": null,
    "origin_task": null,
    "epics": null,
    "epic_order": null,
    "tasks": [],
    "total_attachments": 0,
    "swimlane": null,
    "assigned_users": [],
    "existingTags": [
      [
        "rent",
        "#5551D3"
      ],
      [
        "existing listing",
        "#5178D3"
      ]
    ],
    "checkID": 11650
  },
  {
    "due_date": null,
    "due_date_reason": "",
    "due_date_status": "not_set",
    "total_comments": 0,
    "tags": [
      [
        "rent",
        "#5551D3"
      ],
      [
        "existing listing",
        "#5178D3"
      ]
    ],
    "attachments": [],
    "status": 83,
    "is_watcher": false,
    "total_watchers": 0,
    "is_voter": false,
    "total_voters": 0,
    "project": 14,
    "blocked_note": "",
    "total_points": null,
    "comment": "",
    "origin_issue": null,
    "origin_task": null,
    "epics": null,
    "epic_order": null,
    "tasks": [],
    "total_attachments": 0,
    "swimlane": null,
    "assigned_users": [],
    "existingTags": [
      [
        "rent",
        "#5551D3"
      ],
      [
        "existing listing",
        "#5178D3"
      ]
    ],
    "checkID": 148910
  },
  {
    "due_date": null,
    "due_date_reason": "",
    "due_date_status": "not_set",
    "total_comments": 0,
    "tags": [
      [
        "new listing",
        "#D351CF"
      ],
      [
        "bookable",
        "#ed2891"
      ],
      [
        "rent",
        "#5551D3"
      ],
      [
        "no translation",
        "#CFD350"
      ]
    ],
    "attachments": [],
    "status": 83,
    "status_extra_info": {
      "name": "Passed",
      "color": "#A8E440",
      "is_closed": false
    },
    "is_watcher": false,
    "total_watchers": 0,
    "is_voter": false,
    "total_voters": 0,
    "project": 14,
    "assigned_users": [],
    "existingTags": [
      [
        "new listing",
        "#D351CF"
      ],
      [
        "bookable",
        "#ed2891"
      ],
      [
        "rent",
        "#5551D3"
      ],
      [
        "no translation",
        "#CFD350"
      ]
    ],
    "checkID": 14890
  },
  {
    "due_date": null,
    "due_date_reason": "",
    "due_date_status": "not_set",
    "total_comments": 0,
    "tags": [
      [
        "new listing",
        "#D351CF"
      ],
      [
        "bookable",
        "#ed2891"
      ],
      [
        "deals",
        "#70728F"
      ],
      [
        "no translation",
        "#CFD350"
      ]
    ],
    "attachments": [],
    "status": 83,
    "status_extra_info": {
      "name": "Passed",
      "color": "#A8E440",
      "is_closed": false
    },
    "assigned_to": null,
    "assigned_to_extra_info": null,
    "owner": 19,
    "assigned_users": [],
    "existingTags": [
      [
        "new listing",
        "#D351CF"
      ],
      [
        "bookable",
        "#ed2891"
      ],
      [
        "deals",
        "#70728F"
      ],
      [
        "no translation",
        "#CFD350"
      ]
    ],
    "checkID": 197
  }
]

I want to use a function to add a new item with only the useful part of the tags, for example on the last item in the json above i want to
end up with:
item.brandNewUsefulTags = “new listing”, “bookable”,“rent”, “no translation”;
return item;

I just dont know how to go about iterating over the json[‘tags’] and extracting the first part

Any help would be massively appreciated

Looks like your tags field is an array of arrays (where the nested array has the value you want as the first element). So I’d suggest using a Function Item node with code like this:

item.brandNewUsefulTags = item.tags.map(e => e[0]);
return item;

Or if you only wand the new tags and nothing else

return {
  brandNewUsefulTags: item.tags.map(e => e[0])
};

The .map method transforms an array on the fly, in our case the array in the tags field. So in this example it takes each item in tags, names it e and then returns e[0] (the first item in the e array) instead of the entirety of e. You can check out .map() in more detail here on MDN.

Hope this helps!

Absolute legend!! I spent way too much time, more than I would like to admit, trying to work that out:(

1 Like

Glad to hear this works for, thx for confirming!