Adding a value to an array

Hi,

I need to submit an array as order lines.
I have an array (aggregate to json module) and need to add an additional value (create json module). I was trying to combine this within the post request request body using the ‘add’ function but not getting any success.

Any tips on how to add this additional value to create a single array?




you can use merge function merge(array1;array2)

Thank you. But i’m not sure merge works because the second son isn’t an array, it’s an object?

Is there a way this could be an array? Or i could merge without it being an array?

If I am looking at this correctly what you are trying to do is combine the arrays from aggregate JSON and the array in the next module correct?

The way your modules are setup right now both these things are text and not an actual array, so the add and merge functions will not work. To combine these two json strings you can just map them into the required field with a comma in between. Just remove the brackets from the aggregate module. And add them on the outside of the combine json strings in the final module.

Other way is to use the parse json module to transform both those json strings into an acutal arrays. Then you can use those array functions.

Ahhh that makes sense!

Any tips to removing the brackets from the aggregate module’s string?

Thank you!

Maybe instead of aggregate to JSON use a text aggregator. I personally like using a text aggreagtor over the JSON aggreagtor. It allows for more manipulation and flexibility.

I only use JSON aggreagtor when I am dealing with JSONs with arrays and collections that i do not wish to map out individually.

1 Like

This worked great.

Thank you @LinkYourTech

1 Like