Convert array of [tag1, tag2, tag3] into json {"tags":["tag1","tag2","tag3"]}

I hate getting stuck on such basic things but I’m having troubles putting an array into a JSON output.

:star_struck: The goal is to convert array of [tag1, tag2, tag3] into json {“tags”:[“tag1”,“tag2”,“tag3”]}

This is the array output:

Then I want to send a JSON string to another API. The API is expecting: {“tags”:[“tag1”,“tag2”,“tag3”]}

There is something I’m not getting with the translation.

I’ve tried using this in the API JSON field: {“tags”: {{98.output}}}
But this gives me: {“tags”: tag1, tag2, tag3} (no quotations)

:face_with_open_eyes_and_hand_over_mouth: I’ve also tried “Aggregate to JSON” but output is putting the whole thing in square brackets:

:eyes: If it helps to see the Data Structure setup, I created this structure to handle the tags:

Any thoughts on a simple translation like this?

1 Like

@Tom_Hudock you could check the following two approaches:

  1. Using an iterator and then change the format of each of the values after the iterator, which changes it for each value of the array. After doing that, use an aggregator. This costs a good amount of operations (+1 for each value in the array), though.
  2. Transform an array of objects

@Tom_Hudock

If you are having only issue of square braclet by using aggregate to json, then you can just use functions to remove that in your next module where you are using this output.

i.e {{substring(output;1;length(output)-1)}}

Regards,
Msquare Automation - Platinum Partner of Make
@Msquare_Automation