JSON Manipulation

Hey there,

I’m currently working with the current scenario that:

  • Gets a base from Airtable
  • Gets the tables from that Airtable Base
  • Does some manipulation to get the tables in the following format

{
“tables”: {
“TableOneName”: “tbl123ABC”,
“TableTwoName”: “tbl456DEF”,
“TableThreeName”: “tbl789GHI”
}
}

I’m currently struggling with aggregating the data in the following format, especially with a dynamic JSON here.
What are the steps that I need to take to finalize the JSON manipulation?

Ideally I’d love to do this without using data storage

I also attached a video explaining the flow and the issues

Thanks for the help in advance
R

Welcome to the Make community!

Please provide the output bundles of the module [16] by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
Screenshot_2023-10-06_141025

A.

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading them here will look like this:

module-1-input-bundle.txt (12.3 KB)
module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

This will allow others to better assist you. Thanks!

2 Likes

Hey there, thanks for the response

Here they are:

input_bundle.json (239 Bytes)
output_bundle.json (51.5 KB)

Let me know if these help

Thanks

You’ll need a minimum of three modules:

Give it a go and let us know if you have any issues!

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the code below by clicking the copy button when you mouseover the top-right of the code block
    Screenshot_2024-01-17_200117

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV to paste in the canvas.

  3. Click on each imported module and save it. You may need to remap some variables.

Modules JSON Export

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 86,
                    "module": "builtin:BasicFeeder",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "array": "{{84.body.tables}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 1458,
                            "y": 1012,
                            "name": "Iterate Tables"
                        },
                        "restore": {
                            "expect": {
                                "array": {
                                    "mode": "edit"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "array",
                                "type": "array",
                                "label": "Array",
                                "mode": "edit",
                                "spec": []
                            }
                        ]
                    }
                },
                {
                    "id": 87,
                    "module": "util:TextAggregator",
                    "version": 1,
                    "parameters": {
                        "rowSeparator": "other",
                        "otherRowSeparator": ",",
                        "feeder": 86
                    },
                    "mapper": {
                        "value": "\"{{86.name}}\": \"{{86.id}}\""
                    },
                    "metadata": {
                        "designer": {
                            "x": 1703,
                            "y": 1010,
                            "name": "Aggregate Tables"
                        },
                        "restore": {
                            "parameters": {
                                "rowSeparator": {
                                    "label": "Other"
                                }
                            },
                            "extra": {
                                "feeder": {
                                    "label": "Iterator [86]"
                                }
                            },
                            "flags": {
                                "groupBy": {
                                    "collapsed": true
                                },
                                "stopIfEmpty": {
                                    "collapsed": true
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "rowSeparator",
                                "type": "select",
                                "label": "Row separator",
                                "validate": {
                                    "enum": [
                                        "\n",
                                        "\t",
                                        "other"
                                    ]
                                }
                            },
                            {
                                "name": "otherRowSeparator",
                                "type": "text",
                                "label": "Separator"
                            }
                        ],
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ],
                        "advanced": true
                    }
                },
                {
                    "id": 88,
                    "module": "util:ComposeTransformer",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "value": "{\"tables\":{{{87.text}}}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 1946,
                            "y": 1011,
                            "name": "Make JSON",
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {},
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}
2 Likes