Recursive function replaced with nodes

Hello, input object contains repeating structure.

const CFG=
[
{
  "Name":"HO",
  "Datatype":"Int"
},
{
    "el": {
        "Name": "Type",
        "Datatype": "Struct"
    },
    "AttributeList": [
    ],
    "Member": [
        {
            "el": {
                "Name": "SI",
                "Datatype": "Bool"
            }
        },
        {
            "el": {
                "Name": "SO",
                "Datatype": "Bool"
            }
        },
        {
            "el": {
                "Name": "RA",
                "Datatype": "Bool"
            }
        },
        {
            "el": {
                "Name": "FS",
                "Datatype": "Bool"
            }
        },
        {
            "el": {
                "Name": "TI",
                "Datatype": "Bool"
            }
        },
        {
            "el": {
                "Name": "TO",
                "Datatype": "Bool"
            }
        },
        {
            "el": {
                "Name": "MA",
                "Datatype": "Bool"
            }
        }
    ]
},
{
  "Name":"TO",
  "Datatype":"Bool"
}

rule is if array element has Member property go one level down and join el.Name in lower tier element name. In the end lowest tier elements should be placed in array with the same order they were accessed. The end result would be:

[
    {
        "AddrName": "CFG.HO",
        "Datatype": "Int"

    },
    {
        "Name": "CFG.Type.SI",
        "Datatype": "Bool"
    },
    {
        "Name": "CFG.Type.SO",
        "Datatype": "Bool"
    },
...
    {
        "Name": "CFG.MA",
        "Datatype": "Bool"
    }
]

I was able to write function which kind of does what is necessary:
Flow attached:
ScadaVarParser.json (66.8 KB)

End result should can be found at msg.UDTscada
image

but I would like to convert it into nodered nodes or more simple functions, because it is getting hard to debug all edge cases. But I cannot wrap my head around how to halt processing of upper tier Members until lower tier is not fully processed because order is the critical

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.