Construct

Constructs an array with values stored at numbered keys.

Input Fields

  • *User-Defined*: Here, you will set up the structure of your list, by creating a schema with indices and values. The keys for each item must be the index that you want it placed in within your new list. The highest number integer specified in your schema will be the latest populated index, with all previous values set to null, unless otherwise specified.   

Output Fields

  • list: The list that was created as the result of this module. Note- the output defaults to an array of object, if you would like to change the type, change the “_type” key.

Examples

Here’s an example that illustrates how your keys and values are set up in a List.Construct. In this case, the keys are intentionally out of order, to illustrate that list order is determined by the key used. Also, this illustrates that undefined indices within the constructed list are automatically set to null.

{
    "brick": "list.construct",
    "id": "BJ5s2",
    "inputs": {
        "0": {
            "item": "Thing0"
        },
        "2": {
            "_type": "object",
            "_array": false,
            "_value": {
                "item": "Thing2"
            }
        }
    },
    "outputs": {
        "list": {
            "_type": "object",
            "_array": true
        }
    }
}

Resulting list:

"list": [  
  {  "item": "Thing0"  },  
  null,  
  {  "item": "Thing2"  }  
]