Make.com newbie here. I had 2 Questions:
- Is a collection the same concept as an object in programming?
- I have an array of text. Each record contains a key-value pair that can be split on “:”. What would be the best way to approach this?
Make.com newbie here. I had 2 Questions:
Hello!
1.Yes, a collection is equivalent to an object in programming.
2. This will depend on what you want to do with this data. Do you want to generate a collection that contains fields “Full name”, “Email”, etc? Or anything else?
Benjamin
Welcome to the Make community!
Yes, that is possible. The most straightforward way would require four modules:
Output
Give it a go and let us know if you have any issues!
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.
Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.
{
"subflows": [
{
"flow": [
{
"id": 171,
"module": "json:ParseJSON",
"version": 1,
"parameters": {
"type": ""
},
"mapper": {
"json": "{\n \"message_collection\": [\n \"Full name: John Doe\",\n \"Email: johndor@gmail.com\",\n \"Date: 08/01/2024 at 5:00PM\",\n \"Service: Painting\",\n \"Budget: $5,000.\"\n ]\n}"
},
"metadata": {
"designer": {
"x": -2310,
"y": -1376,
"name": "Example Data"
},
"restore": {
"parameters": {
"type": {
"label": "Choose a data structure"
}
}
},
"parameters": [
{
"name": "type",
"type": "udt",
"label": "Data structure"
}
],
"expect": [
{
"name": "json",
"type": "text",
"label": "JSON string",
"required": true
}
]
}
},
{
"id": 173,
"module": "builtin:BasicFeeder",
"version": 1,
"parameters": {},
"mapper": {
"array": "{{171.message_collection}}"
},
"metadata": {
"designer": {
"x": -2060,
"y": -1377
},
"restore": {
"expect": {
"array": {
"mode": "edit"
}
}
},
"expect": [
{
"name": "array",
"type": "array",
"label": "Array",
"mode": "edit",
"spec": []
}
]
}
},
{
"id": 177,
"module": "util:SetVariables",
"version": 1,
"parameters": {},
"mapper": {
"variables": [
{
"name": "key",
"value": "{{first(split(173.value; \": \"))}}"
},
{
"name": "value",
"value": "{{last(split(173.value; \": \"))}}"
}
],
"scope": "roundtrip"
},
"metadata": {
"designer": {
"x": -1815,
"y": -1378
},
"restore": {
"expect": {
"variables": {
"items": [
null,
null
]
},
"scope": {
"label": "One cycle"
}
}
},
"expect": [
{
"name": "variables",
"type": "array",
"label": "Variables",
"spec": [
{
"name": "name",
"label": "Variable name",
"type": "text",
"required": true
},
{
"name": "value",
"label": "Variable value",
"type": "any"
}
]
},
{
"name": "scope",
"type": "select",
"label": "Variable lifetime",
"required": true,
"validate": {
"enum": [
"roundtrip",
"execution"
]
}
}
],
"interface": [
{
"name": "key",
"label": "key",
"type": "any"
},
{
"name": "value",
"label": "value",
"type": "any"
}
]
}
},
{
"id": 178,
"module": "builtin:BasicAggregator",
"version": 1,
"parameters": {
"feeder": 173
},
"mapper": {
"key": "{{177.key}}",
"value": "{{177.value}}"
},
"metadata": {
"designer": {
"x": -1569,
"y": -1377
},
"restore": {
"extra": {
"feeder": {
"label": "Iterator [173]"
},
"target": {
"label": "Custom"
}
}
}
}
},
{
"id": 179,
"module": "util:SetVariable2",
"version": 1,
"parameters": {},
"mapper": {
"name": "variables",
"scope": "roundtrip",
"value": "{{toCollection(178.array; \"key\"; \"value\")}}"
},
"metadata": {
"designer": {
"x": -1325,
"y": -1382
},
"restore": {
"expect": {
"scope": {
"label": "One cycle"
}
}
},
"expect": [
{
"name": "name",
"type": "text",
"label": "Variable name",
"required": true
},
{
"name": "scope",
"type": "select",
"label": "Variable lifetime",
"required": true,
"validate": {
"enum": [
"roundtrip",
"execution"
]
}
},
{
"name": "value",
"type": "any",
"label": "Variable value"
}
],
"interface": [
{
"name": "variables",
"label": "variables",
"type": "any"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}
samliew – request private consultation
Join the Make Fans Discord server to chat with other makers!
This worked! Thank you @samliew