Assign String to a Collection

Is it possible to assign a string to a collection directly and that Make parse it if it’s properly formated?
Haven’t found a way/format that works.


Collection Foo
   - Bar1: String
   - Bar2: Number

Field1: Foo

Have something like:
Field1 <-- { [ "Bar1", "Beer"], ["Bar2", "2534"]}

Obviously the structure will be much more complicated and dynamic, hence the need for a direct assignment.

Many thanks to all

Looks like you’re creating a collection of arrays. Tocollection() would work and you can create the arrays with a map().

Show us what you’ve tried already and we can get you further.

Actually, I’ve tried every permutation of every function :'D

I’m just trying to create a Collection with two fields in this example
It should end as:


toCollection (very poorly documented, I spent hours trying to understand how it treated the input data), takes in input an array, each row of the array being a key-value pair representing FieldName and FieldValue for the target collection. That’s why I was trying to format my input string as { [ “Bar1”, “Beer”], [“Bar2”, “2534”]}

But It can’t transform the string into a collection it seems. toCollection( { [ “Bar1”, “Beer”], [“Bar2”, “2534”]}) fails to execute too.

What works is toCollection(add(add(),add()) but it works just for this simple example, and in my case I have an array of indefinite number of collections. As there is no iterative or recursive functions, I can’t do it directly in one field. Hence my search for a string pattern allowing to assign this string to a Collection field.

Hope this is clearer :slight_smile:

Have you tried an iterator (under tools) that sends each part of your collection and then have a set variable step that adds to the array iteratively. There’s no recursion but there is an iterator.

Yep, but I wanted to overload my scenario with lots of modules, and wanted to do that inline in one script.
I’m trying to do it right now by generating a JSON string and parsing it with the JSON parser module. It just adds 1 module. Just having formatting issues.

It’s really hard to overload Make. Easy to read and manage scenarios are broken down into multiple modules. If you are trying to design your scenario to conserve operations you may really be spending a ton of time trying to optimize for no really good reason. 1000 operations for free will be burned just testing.

Use an iterator after Parse Json or just get the raw array data and eliminate the use of json.

My mistake, I didn’t want to overload my scenario :smiley:
Yep, just generating the string and parsing it with JSON Parse delivers the objects.

1 Like

So, I finally did it this way:
Generate a JSON formatted string
Use the JSON parser module to parse it into an array of collections.
1 step :slight_smile:

1 Like