title: Convert/Export JSON to CSV
body: <p>JSON file:</p>
  
  <pre><code>"UserDetailList": [
          {
              "UserName": "citrix-xendesktop-ec2-provisioning", 
              "GroupList": [], 
              "CreateDate": "2017-11-07T14:20:14Z", 
              "UserId": "1234556", 
              "Path": "/", 
              "AttachedManagedPolicies": [
                  {
                      "PolicyName": "AmazonEC2FullAccess", 
                      "PolicyArn": "arn:aws:iam::aws:policy/AmazonEC2FullAccess"
                  }, 
                  {
                      "PolicyName": "AmazonS3FullAccess", 
                      "PolicyArn": "arn:aws:iam::aws:policy/AmazonS3FullAccess"
                  }
              ], 
              "Arn": "arn:aws:iam::1234567890:user/citrix-xendesktop-ec2-provisioning"
          }, 
          {
              "UserName": "rundeck-read-only-iam-permissions", 
              "GroupList": [], 
              "CreateDate": "2018-03-09T11:13:38Z", 
              "UserId": "AIDAJQOQGKISLCWDXG6EQ", 
              "Path": "/", 
              "AttachedManagedPolicies": [
                  {
                      "PolicyName": "IAMReadOnlyAccess", 
                      "PolicyArn": "arn:aws:iam::aws:policy/IAMReadOnlyAccess"
                  }
              ], 
              "Arn": "arn:aws:iam::279052847476:user/rundeck-read-only-iam-permissions"
          }
      ]
  </code></pre>
  
  <p>with </p>
  
  <pre><code>jq -r '.UserDetailList[] | [.UserName] | @csv' output.json &gt; fileout2.csv
  </code></pre>
  
  <p>I can get</p>
  
  <pre><code>citrix-xendesktop-ec2-provisioning"
  "rundeck-read-only-iam-permissions"
  </code></pre>
  
  <p>How to get IAM policies for these 2 users, i need to extract AmazonEC2FullAccess and AmazonS3FullAccess under AttachedManagedPolicies ?</p>
  
  <p>so output can be</p>
  
  <pre><code>citrix-xendesktop-ec2-provisioning",AmazonEC2FullAccess
  citrix-xendesktop-ec2-provisioning",AmazonS3FullAccess
  rundeck-read-only-iam-permissions,IAMReadOnlyAccess
  </code></pre>