Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

Remove Duplicate Array Values

$
0
0

I am using the following jq query to extract the AWS ARN and associated protocols. However I only need the ARN to be listed once followed by the ports and protocols

my code is jq -r '.Listeners[] | (.LoadBalancerArn), (.Protocol)' and the results are

"arn:aws:elasticloadbalancing:us-xxxx-1:123456789:loadbalancer/app/msword-123456789/20b73abcde""HTTP""arn:aws:elasticloadbalancing:us-xxxx-1:123456789:loadbalancer/app/msword-123456789/20b73abcde""HTTP""arn:aws:elasticloadbalancing:us-xxxx-1:123456789:loadbalancer/app/msword-123456789/20b73abcde""HTTPS"

I have tried everything including unique, first, unique_by, select, contains, etc.. and the results are always "Cannot iterate over string" or number

Desired results

"arn:aws:elasticloadbalancing:us-xxxx-1:123456789:loadbalancer/app/msword-123456789/20b73abcde""HTTP""HTTP""HTTPS"

Sample JSON

{"Listeners": [        {        "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-xxxx-1:123456789:loadbalancer/app/msword-123456789/20b73abcde","Port": 9090,"Protocol": "HTTP"        },        {        "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-xxxx-1:123456789:loadbalancer/app/msword-123456789/20b73abcde","Port": 80,"Protocol": "HTTP"            },        {       "LoadBalancerArn": "arn:aws:elasticloadbalancing:us-xxxx-1:123456789:loadbalancer/app/msword-123456789/20b73abcde","Port": 443,"Protocol": "HTTPS"        }    ]}

Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>