Expand my Community achievements bar.

How to create a complex (associative) Array or Collection in Fusion?

Avatar

Level 1

I am looking to create an associative array. That is to say an Array that uses Key/Value Pairs instead of indexes.

 

Alternatively, I would be just as happy to be able to create a Collection (as that has key/value pairs)

 

BUT, it seems that there is no way to create these things... only ways to read them and get information out of them.

 

Can anyone add any insight to this?

 

It's shouldn't be rocket science:

 

Array_Name = [

   "first_name": "Wes",

    "last_name": "Denaro",

    "frustration_level": "elevated"

]

 

There is no documentation that outlines how to create this. In addition, Fusion support could not provide any clarity as to IF it is even possible.

 

Thanks for your help Community!

 

Wes-

 

Tagging my support Engineer

@JamesRitter 

 

2 Replies

Avatar

Community Advisor

To make sure, you are wanting to build a collection so you can call for values by asking for a key? Is it a single collection, or an array of collections? Are the keys always going to be the same? (P.S., loving your example)

 

If so, one way to do it in Fusion using the toCollection function, but I have not yet been able to figure out the formatting to make that function work.

 

The way I do it for now, until I can figure that out, is to use the build JSON module to make a JSON string (or you could build your JSON string manually), and then run that JSON string thru the Parse JSON module, which will give you a collection. If you're looking for an array of collections, then you can use a set multiple variables module. The variable name is the key, the variable value will become the value, and then collect the variables in an aggregator module. Both of these methods assume the keys are always the same.

Avatar

Level 1

Yes, the documentation is not clear enough. However, in my use case, I was able to create a simple array in Iterator module using the function - add(emptyarray;<values>). You could use the same function in other modules as well. Also, I have not been able to identify any other ways to create complex arrays yet. 

 

Reference: https://experienceleague.adobe.com/docs/workfront/using/adobe-workfront-fusion/functions-in-fusion/a...