title: How to access a value of a dictionary inside a dictionary within a list using python
body: <p>I have the following json object that I am trying to extract some value - <code>name</code> field under the <code>items</code> list.</p>
  <pre><code>{
      &quot;apiVersion&quot;:&quot;aquasecurity.github.io/v1alpha1&quot;,
      &quot;items&quot;:[
         {
            &quot;apiVersion&quot;:&quot;aquasecurity.github.io/v1alpha1&quot;,
            &quot;kind&quot;:&quot;VulnerabilityReport&quot;,
            &quot;metadata&quot;:{
               &quot;annotations&quot;:{
                  &quot;trivy-operator.aquasecurity.github.io/report-ttl&quot;:&quot;730h0m0s&quot;
               },
               &quot;name&quot;:&quot;cronjob-eks-upgrade-notifier-eks-upgrade-notifier&quot;,
               &quot;namespace&quot;:&quot;devops&quot;,             
               &quot;resourceVersion&quot;:&quot;174823549&quot;,
               &quot;uid&quot;:&quot;c93d513a-a940-4c5c-a8ec-f83a9b67b2cd&quot;
            },
            &quot;report&quot;:{
               &quot;artifact&quot;:{
                  &quot;repository&quot;:&quot;myrepo/k8s-eks-upgrade-agent&quot;,
                  &quot;tag&quot;:&quot;9478954&quot;
               },
               &quot;registry&quot;:{
                  &quot;server&quot;:&quot;&lt;account-id&gt;.dkr.ecr.eu-central-1.amazonaws.com&quot;
               },
               &quot;scanner&quot;:{
                  &quot;name&quot;:&quot;Trivy&quot;,
                  &quot;vendor&quot;:&quot;Aqua Security&quot;,
                  &quot;version&quot;:&quot;0.30.0&quot;
               },
               &quot;summary&quot;:{
                  &quot;criticalCount&quot;:1,
                  &quot;highCount&quot;:4,
                  &quot;lowCount&quot;:0,
                  &quot;mediumCount&quot;:0,
                  &quot;noneCount&quot;:0,
                  &quot;unknownCount&quot;:0
               },
               &quot;updateTimestamp&quot;:&quot;2022-09-05T15:02:24Z&quot;,
               &quot;vulnerabilities&quot;:[
                  {
                     &quot;fixedVersion&quot;:&quot;1.35.0-r15&quot;,
                     &quot;installedVersion&quot;:&quot;1.35.0-r13&quot;,
                     &quot;links&quot;:[
                        
                     ],
                     &quot;primaryLink&quot;:&quot;https://avd.aquasec.com/nvd/cve-2022-30065&quot;,
                     &quot;resource&quot;:&quot;busybox&quot;,
                     &quot;score&quot;:6.2,
                     &quot;severity&quot;:&quot;HIGH&quot;,
                     &quot;target&quot;:&quot;&quot;,
                     &quot;title&quot;:&quot;busybox: A use-after-free in Busybox's awk applet leads to denial of service&quot;,
                     &quot;vulnerabilityID&quot;:&quot;CVE-2022-30065&quot;
                  }                
               ]
            }
         },
         {
            &quot;apiVersion&quot;:&quot;aquasecurity.github.io/v1alpha1&quot;,
            &quot;kind&quot;:&quot;VulnerabilityReport&quot;,
            &quot;metadata&quot;:{
               &quot;annotations&quot;:{
                  &quot;trivy-operator.aquasecurity.github.io/report-ttl&quot;:&quot;730h0m0s&quot;
               },
               &quot;name&quot;:&quot;replicaset-bg-cm-operator-b9f798f4-bg-cm-operator&quot;,
               &quot;namespace&quot;:&quot;devops&quot;,             
               &quot;resourceVersion&quot;:&quot;175193254&quot;,
               &quot;uid&quot;:&quot;b9c9830e-95f0-45e9-871c-d0ccef97abcb&quot;
            },
            &quot;report&quot;:{
               &quot;artifact&quot;:{
                  &quot;repository&quot;:&quot;myrepo7/k8s-blue-green-cm-operator&quot;,
                  &quot;tag&quot;:&quot;5c7cbca&quot;
               },
               &quot;registry&quot;:{
                  &quot;server&quot;:&quot;&lt;account-id&gt;.dkr.ecr.eu-central-1.amazonaws.com&quot;
               },
               &quot;scanner&quot;:{
                  &quot;name&quot;:&quot;Trivy&quot;,
                  &quot;vendor&quot;:&quot;Aqua Security&quot;,
                  &quot;version&quot;:&quot;0.30.0&quot;
               },
               &quot;summary&quot;:{
                  &quot;criticalCount&quot;:1,
                  &quot;highCount&quot;:5,
                  &quot;lowCount&quot;:0,
                  &quot;mediumCount&quot;:0,
                  &quot;noneCount&quot;:0,
                  &quot;unknownCount&quot;:0
               },
               &quot;updateTimestamp&quot;:&quot;2022-09-06T06:26:24Z&quot;,
               &quot;vulnerabilities&quot;:[
                  {
                     &quot;fixedVersion&quot;:&quot;1.3.2-r1&quot;,
                     &quot;installedVersion&quot;:&quot;1.3.2-r0&quot;,
                     &quot;links&quot;:[
                        
                     ],
                     &quot;primaryLink&quot;:&quot;https://avd.aquasec.com/nvd/cve-2021-46828&quot;,
                     &quot;resource&quot;:&quot;libtirpc&quot;,
                     &quot;score&quot;:7.5,
                     &quot;severity&quot;:&quot;HIGH&quot;,
                     &quot;target&quot;:&quot;&quot;,
                     &quot;title&quot;:&quot;libtirpc: DoS vulnerability with lots of connections&quot;,
                     &quot;vulnerabilityID&quot;:&quot;CVE-2021-46828&quot;
                  }                
               ]
            }
         }
      ],
      &quot;kind&quot;:&quot;VulnerabilityReportList&quot;,
      &quot;metadata&quot;:{
         &quot;continue&quot;:&quot;&quot;,
         &quot;resourceVersion&quot;:&quot;184454555&quot;
      }
   }
  </code></pre>
  <p>I tried the following code but it gives me the output as single letters:</p>
  <pre><code>def get_all_vulnerability_reports():
      logging.info(&quot;Getting all the \&quot;vuln\&quot; type objects in * namespaces&quot;)
      connect_to_k8s_cluster()
      vuln_reports = set()
  
      with k8s_client.ApiClient() as api_client:
          api_instance = k8s_client.CustomObjectsApi(api_client)
          try:
              # vuln_list = api_instance.list_cluster_custom_object(group=&quot;aquasecurity.github.io&quot;, version=&quot;v1alpha1&quot;, plural=&quot;vulnerabilityreports&quot;, )
              vuln_list = api_instance.list_namespaced_custom_object(group=&quot;aquasecurity.github.io&quot;, version=&quot;v1alpha1&quot;, plural=&quot;vulnerabilityreports&quot;, pretty=&quot;true&quot;, namespace=&quot;devops&quot; )
              
              # print(json.dumps(vuln_list))
          except ApiException as e:
              logging.exception(&quot;Exception when trying to get list of  \&quot;vuln\&quot; reports&quot;, exc_info=e)
          else:
  
              for items in json.dumps(vuln_list):
                  for item in items:
                      print (item)
          
      return vuln_reports
  </code></pre>
  <p>Can someone help me to fix this?</p>
  <p>I need the <code>items.name</code> value.</p>