Returning Json mit dynamic Number of Values

Hello There.
I am desperatly trying to find a solution and cant seem to figure out how to handle things.

My input data contains a certain (dynamic) numbers of x and y values i need to transform into a json, specific to this data structure:

{“name”:
[
[
[x(1),y(1)],
[x(2), y(2)],
[x(n),y(n)],
]
]
}

So far i’ve tried to set values for the input array and transform them with the create Json module regardless if the value is existing or not. This ends up for the json to text “null” at the positon of the empty values. Also i tried to use the iterator and use the module aggregate to json wich left me with multiple jsons i couldn’t manage to get into one in the right structure.

I appriciate every ideas or pointings in the right direction.
Thanks in advance.




Welcome to the Make community!

Please provide the output bundles of the modules shown in your screenshot above 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. Thank u for taking ur time in the first place.
Unfortunately i am unable to upload .txt files

Here i am using to code format:
0. Input Data

[
    {
        "array": [
            {
                "edits": {
                    "0": {
                        "id": 0,
                        "features": {
                            "adds": [
                                {
                                    "geometry": {
                                        "paths": [
                                            [
                                                [
                                                    1231429.55793092,
                                                    6624931.74519834
                                                ],
                                                [
                                                    1231914.0089778,
                                                    6624613.26868161
                                                ],
                                                [
                                                    1231970.96200376,
                                                    6623928.03069258
                                                ],
                                                [
                                                    1231017.03385147,
                                                    6624843.24279841
                                                ]
                                            ]
                                        ]
                                    },
                                    "attributes": {
                                        "OBJECTID": 6,
                                        "GlobalID": "DB68F29D-851B-4149-9AC2-06E70AF96001"
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        ],
        "__IMTAGGLENGTH__": 1
    }
]
  1. Output Iterator
[
    {
        "value": [
            1231429.55793092,
            6624931.74519834
        ],
        "__IMTINDEX__": 1,
        "__IMTLENGTH__": 4
    },
    {
        "value": [
            1231914.0089778,
            6624613.26868161
        ],
        "__IMTINDEX__": 2,
        "__IMTLENGTH__": 4
    },
    {
        "value": [
            1231970.96200376,
            6623928.03069258
        ],
        "__IMTINDEX__": 3,
        "__IMTLENGTH__": 4
    },
    {
        "value": [
            1231017.03385147,
            6624843.24279841
        ],
        "__IMTINDEX__": 4,
        "__IMTLENGTH__": 4
    }
]
  1. Output Array aggregator
[
    {
        "array": [
            {
                "value": [
                    1231429.55793092,
                    6624931.74519834
                ],
                "__IMTINDEX__": 1,
                "__IMTLENGTH__": 4
            },
            {
                "value": [
                    1231914.0089778,
                    6624613.26868161
                ],
                "__IMTINDEX__": 2,
                "__IMTLENGTH__": 4
            },
            {
                "value": [
                    1231970.96200376,
                    6623928.03069258
                ],
                "__IMTINDEX__": 3,
                "__IMTLENGTH__": 4
            },
            {
                "value": [
                    1231017.03385147,
                    6624843.24279841
                ],
                "__IMTINDEX__": 4,
                "__IMTLENGTH__": 4
            }
        ],
        "__IMTAGGLENGTH__": 4
    }
]

  1. Output Set Variables
[
    {
        "array": [
            {
                "value": [
                    1231429.55793092,
                    6624931.74519834
                ],
                "__IMTINDEX__": 1,
                "__IMTLENGTH__": 4
            },
            {
                "value": [
                    1231914.0089778,
                    6624613.26868161
                ],
                "__IMTINDEX__": 2,
                "__IMTLENGTH__": 4
            },
            {
                "value": [
                    1231970.96200376,
                    6623928.03069258
                ],
                "__IMTINDEX__": 3,
                "__IMTLENGTH__": 4
            },
            {
                "value": [
                    1231017.03385147,
                    6624843.24279841
                ],
                "__IMTINDEX__": 4,
                "__IMTLENGTH__": 4
            }
        ],
        "__IMTAGGLENGTH__": 4
    }
]

  1. Output Create Json
[
    {
        "json": "{\"paths\":[[[1231429.55793092,6624931.74519834],[1231914.0089778,6624613.26868161],[1231970.96200376,6623928.03069258],[1231017.03385147,6624843.24279841],null]]}"
    }
]