Restructure JSON Payload

Andreas
Tera Contributor

Hello,

I am currently attempting to build, or should I say, restructure the JSON payload from the Catalog Item for the Tufin API. The JSON structure I receive originates from the ServiceNow Catalog Item and appears as follows:

 

    "Network Data": [
        {
            "comment": "Test",
            "ports": "esp,icmp,60/tcp",
            "source_ip_addresses": "127.0.0.1/24,128.0.0.1,10.0.0.0-10.0.0.255",
            "target_ip_addresses": "127.0.0.1/24,128.0.0.1,10.0.0.0-10.0.0.255"
        },
        {
            "comment": "Test",
            "ports": "icmp,esp,100/udp",
            "source_ip_addresses": "10.10.10.10",
            "target_ip_addresses": "20.20.20.20,20.30.20.20-40.50.40.40"
        }
    ]​

 

 

And i need it to be formated in this structure.

 

{
    "order": "AR1",
    "sources": {
        "source": [
            {
                "@type": "IP",
                "ip_address": "10.10.10.10",
                "cidr": "/32"
            }
        ]
    },
    "destinations": {
        "destination": [
            {
                "@type": "IP",
                "ip_address": "10.20.30.40",
                "cidr": "/32"
            }
        ]
    },
    "services": {
        "service": [
            {
                "@type": "PROTOCOL",
                "protocol": "TCP",
                "port": "100"
            }
        ]
    },
    "comment": "test"
},
{
    "order": "AR2",
    "sources": {
        "source": [
            {
                "@type": "IP",
                "ip_address": "30.30.30.30",
                "cidr": "/24"
            }
        ]
    },
    "destinations": {
        "destination": [
            {
                "@type": "IP",
                "ip_address": "40.40.40.40",
                "cidr": "/32"
            }
        ]
    },
    "services": {
        "service": [
            {
                "@type": "PROTOCOL",
                "protocol": "TCP",
                "port": "9999"
            }
        ]
    },
    "comment": "test"
}

 

I know that the payloads have different inputs, but this shouldn't bother as only the scheme/structure matters. I already have a script that maps/restructures the JSON payload. However, the requirement is to build the structure, ideally completely without code and only with no or low code in the flow designer. Do you think it's possible to achieve this?

0 REPLIES 0