title: python extracting specific key and value from json not working
body: <p>I'm trying to extract a specific key and value from json in windows with Python. </p>
  
  <p>I'd like to use the dumps command, but can't find a good example. </p>
  
  <p>**Updated data: An extract from the json file is (but the file is very long):</p>
  
  <pre><code>   {
    "CVE_data_type" : "CVE",
    "CVE_data_format" : "MITRE",
    "CVE_data_version" : "4.0",
    "CVE_data_numberOfCVEs" : "64",
    "CVE_data_timestamp" : "2020-01-09T08:00Z",
    "CVE_Items" : [ {
      "cve" : {
        "data_type" : "CVE",
        "data_format" : "MITRE",
        "data_version" : "4.0",
        "CVE_data_meta" : {
          "ID" : "CVE-2020-0001",
          "ASSIGNER" : "cve@mitre.org"
        },
        "problemtype" : {
          "problemtype_data" : [ {
            "description" : [ ]
          } ]
        },
        "references" : {
          "reference_data" : [ {
            "url" : "https://source.android.com/security/bulletin/2020-01-01",
            "name" : "https://source.android.com/security/bulletin/2020-01-01",
            "refsource" : "CONFIRM",
            "tags" : [ ]
          } ]
        },
        "description" : {
          "description_data" : [ {
            "lang" : "en",
            "value" : "In getProcessRecordLocked of ActivityManagerService.java isolated apps are not handled correctly. This could lead to local escalation of privilege with no additional execution privileges needed. User interaction is not needed for exploitation. Product: Android Versions: Android-8.0, Android-8.1, Android-9, and Android-10 Android ID: A-140055304"
          } ]
        }
      },
      "configurations" : {
        "CVE_data_version" : "4.0",
        "nodes" : [ ]
      },
      "impact" : { },
      "publishedDate" : "2020-01-08T19:15Z",
      "lastModifiedDate" : "2020-01-08T20:01Z"
    }, {
      "cve" : {
        "data_type" : "CVE",
        "data_format" : "MITRE",
        "data_version" : "4.0",
        "CVE_data_meta" : {
          "ID" : "CVE-2020-0002",
          "ASSIGNER" : "cve@mitre.org"
        },
        "problemtype" : {
          "problemtype_data" : [ {
            "description" : [ ]
          } ]
        },
        "references" : {
          "reference_data" : [ {
            "url" : "https://source.android.com/security/bulletin/2020-01-04",
            "name" : "https://source.android.com/security/bulletin/2020-01-04",
            "refsource" : "CONFIRM",
            "tags" : [ ]
          } ]
        },
        "description" : {
          "description_data" : [ {
            "lang" : "en",
            "value" : "In ih264d_init_decoder of ih264d_api.c, there is a possible out of bounds write due to a use after free. This could lead to remote code execution with no additional execution privileges needed. User interaction is needed for exploitation Product: Android Versions: Android-8.0, Android-8.1, Android-9, and Android-10 Android ID: A-142602711"
          } ]
        }
      },
      "configurations" : {
        "CVE_data_version" : "4.0",
        "nodes" : [ ]
      },
  
      ...
  </code></pre>
  
  <p>I need to extract the ID and description.</p>
  
  <p>I tried this</p>
  
  <pre><code>for key, value in json.dumps(cve_dict['CVE_Items'][0], sort_keys=True, indent=4, separators=',', ': ')):
      #if(key in ['ID', 'description']):
      print(key, value)
  </code></pre>
  
  <p>But I get this error:</p>
  
  <pre><code>  File "unzip_get_info.py", line 19
      for key, value in json.dumps(cve_dict['CVE_Items'][0], sort_keys=True, indent=4, separators=',', ': ')):
                                                                                                            ^
  SyntaxError: invalid syntax
  </code></pre>
  
  <p>I can get the whole json to print out with this:</p>
  
  <pre><code>print(json.dumps(cve_dict['CVE_Items'][0], sort_keys=True, indent = 4, separators=(',', ': ')))
  </code></pre>
  
  <p>I'm not a huge python programmer.  Any idea how I can get the key/value of ID and description out?  I tried doing it directly with cve_dict, but the error was something about how I can't do that directly.</p>
  
  <p>I'd appreciate the help.  This is my first python program.</p>
  
  <p>I'm trying to figure out how to do it with dumps with this <a href="https://realpython.com/python-json/" rel="nofollow noreferrer">link</a>, but I'm not seeing it.  I looked at <a href="https://stackoverflow.com/questions/12353288/getting-values-from-json-using-python">this too</a>, but I'm not sure.</p>
  
  <p>**Update:  I tried </p>
  
  <pre><code>for key, value in cve_dict['CVE_Items'][0].items():
      if(key in ['ID', 'description']):
          print(key, value)
  </code></pre>
  
  <p>trying to limit it to ID and description, in addition to what was suggested below, but it's not printing anything.  I know ID and description are in there (see json above).  How do I just print ID and description, and not all the key/values?</p>