I have the following JSON content and I am trying to parse it by using perl (use JSON qw( decode\_json );

here you have the complete JSON content,

```
{
  "page": {
    "currentPage": 1,
    "totalPages": 1,
    "pageSize": 45
  },
  "networkelements": [
    {
      "name": "aRestPM",
      "alias": "",
      "networkAddresses": [
        {
          "address": "135.244.37.111",
          "port": 443,
          "restResourceId": "135.244.37.111:443",
          "connectionProtocol": "ADAPTER_MANAGED"
        },
        {
          "address": "10.206.198.182",
          "port": 443,
          "restResourceId": "10.206.198.182:443",
          "connectionProtocol": "ADAPTER_MANAGED"
        }
      ],
      "adapter": {
        "name": "Simple RestService V1.0",
        "version": "19.0.SR5a-STD-0.50_PM-SNAPSHOT"
      },
      "vendor": "Simple",
      "model": "RestService",
      "version": "V1.0",
      "creationTime": "2022-04-07T20:32:22.368-0000",
      "agentGroupName": "DefaultAgentGroup",
      "connectivityState": "IN_CONTACT_CONDITIONAL",
      "interfaces": [
        {
          "name": "REST",
          "networkAddresses": [
            {
              "address": "135.244.37.111",
              "port": 443
            },
            {
              "address": "10.206.198.182",
              "port": 443
            }
          ],
          "sessionCredentialAAAServer": "AAA",
          "sessionCredential": {
            "userId": "dummy"
          },
          "adminState": "ON_DEMAND",
          "sessionAddresses": {},
          "additionalAttributes": {}
        }
      ],
      "customAttributes": {},
      "managementState": "MANAGED",
      "emsServer": "No"
    },
    {
      "name": "aRestPM_443",
      "alias": "",
      "networkAddresses": [
        {
          "address": "10.154.74.91",
          "port": 443,
          "restResourceId": "10.154.74.91:443",
          "connectionProtocol": "ADAPTER_MANAGED"
        }
      ],
      "adapter": {
        "name": "Simple RestService V1.0",
        "version": "19.0.SR5a-STD-0.50_PM-SNAPSHOT"
      },
      "vendor": "Simple",
      "model": "RestService",
      "version": "V1.0",
      "creationTime": "2022-05-16T13:06:01.928-0000",
      "agentGroupName": "DefaultAgentGroup",
      "connectivityState": "IN_CONTACT_CONDITIONAL",
      "interfaces": [
        {
          "name": "REST",
          "networkAddresses": [
            {
              "address": "10.154.74.91",
              "port": 443
            }
          ],
          "sessionCredential": {
            "userId": "dummy"
          },
          "adminState": "ON_DEMAND",
          "sessionAddresses": {},
          "additionalAttributes": {}
        }
      ],
      "customAttributes": {},
      "managementState": "MANAGED",
      "emsServer": "No"
    }
  ]
}

```

I need to print name from networkelements array and address and ip from networkAddresses

the given json is in $keycloak\_response

```
$decoded = decode_json($keycloak_response);
my @networkelements = @{ $decoded->{'networkelements'} };
my @net             = @{ $decoded->{"networkelements"}[0]{"networkAddresses"} };
#print Dumper \@net;

foreach my $ne ( @networkelements ) {
    $ne_name = $ne->{"name"};
    $decoded2 = decode_json($ne);
    my @net = @{ $decoded2->{"networkAddresses"} };
    foreach my $ne ( @net) {
        print $ne_name . "," . $ne->{"address"} . "," . $ne->{"port"} . "\n";
    }
}

```

expected result is

```
aRestPM,135.244.37.111,443
aRestPM,10.206.198.182,443
aRestPM_443,10.154.74.91,443

```

I would really appreciate any advice.

Thanks