Reference

jq Command Line Reference

JQ Reference JSON Data {"Records":[{"eventVersion":"1.05","userIdentity":{"type":"AssumedRole","principalId":"AROAIKZBKHVPCNMTX2M7Y:al-cloud_explorer","arn":"arn:aws:sts::056128891991:assumed-role/alertlogic-iam-role-cd-ful-ALIamRolecdfull20160426-1JFOEMVG88FOK/al-cloud_explorer","accountId":"056128891991","accessKeyId":"ASIAQ2EMK5RLS4OHRA4A","sessionContext":{"attributes":{"mfaAuthenticated":"false","creationDate":"2019-03-01T02:07:20Z"},"sessionIssuer":{"type":"Role","principalId":"AROAIKZBKHVPCNMTX2M7Y","arn":"arn:aws:iam::056128891991:role/alertlogic-iam-role-cd-ful-ALIamRolecdfull20160426-1JFOEMVG88FOK","accountId":"056128891991","userName":"alertlogic-iam-role-cd-ful-ALIamRolecdfull20160426-1JFOEMVG88FOK"}}},"eventTime":"2019-03-01T02:07:58Z","eventSource":"elasticloadbalancing.amazonaws.com","eventName":"DescribeLoadBalancers","awsRegion":"ap-northeast-1","sourceIPAddress":"54.84.151.1............... Remove outer array jq '.[] Output: [ { "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "AROAIKZBKHVPCNMTX2M7Y:al-cloud_explorer", "arn": "arn:aws:sts::056128891991:assumed-role/alertlogic-iam-role-cd-ful-ALIamRolecdfull20160426-1JFOEMVG88FOK/al-cloud_explorer", "accountId": "056128891991", Remove Both outer arrays jq '.[]|.[]' Output: { "eventVersion": "1.05", "userIdentity": { "type": "AssumedRole", "principalId": "AROAIKZBKHVPCNMTX2M7Y:al-cloud_explorer", "arn": "arn:aws:sts::056128891991:assumed-role/alertlogic-iam-role-cd-ful-ALIamRolecdfull20160426-1JFOEMVG88FOK/al-cloud_explorer", "accountId": "056128891991", Return the value in the eventSource field jq '.[] | .[] | .eventSource' Output: "elasticloadbalancing.amazonaws.com" "elasticloadbalancing.amazonaws.com" "elasticloadbalancing.amazonaws.com" "ec2.amazonaws.com" "ec2.amazonaws.com" "ec2.amazonaws.com" "ec2.amazonaws.com" "ec2.amazonaws.com" "ec2.amazonaws.com" "ec2.amazonaws.com" "ec2.