title: how to retrieve all "name" & "id" from json file in python3
body: <p>How can i retrieve all name and id from json file.This is a short version of my json file. I want to retrieve all names and id's so that i can match them with my variable. Then i can triger some work on it.So please help me to retrieve all Id and name. I searched in google but couldn't find. Every example was of single json.</p>
  <pre><code>[
   {
      &quot;id&quot;: 707860,
      &quot;name&quot;: &quot;Hurzuf&quot;,
      &quot;country&quot;: &quot;UA&quot;,
      &quot;coord&quot;: {
        &quot;lon&quot;: 34.283333,
        &quot;lat&quot;: 44.549999
      }
    },
    {
      &quot;id&quot;: 519188,
      &quot;name&quot;: &quot;Novinki&quot;,
      &quot;country&quot;: &quot;RU&quot;,
      &quot;coord&quot;: {
        &quot;lon&quot;: 37.666668,
        &quot;lat&quot;: 55.683334
      }
    },
    {
      &quot;id&quot;: 1283378,
      &quot;name&quot;: &quot;Gorkhā&quot;,
      &quot;country&quot;: &quot;NP&quot;,
      &quot;coord&quot;: {
        &quot;lon&quot;: 84.633331,
        &quot;lat&quot;: 28
      }
    }
  ]
  </code></pre>
  <p>Here's My Code:</p>
  <pre><code>import json
  
  with open('city.list.json') as f:
      data = json.load(f)
  for p_id in data:
      hay = p_id.get('name')
  </code></pre>
  <p>suppose,i got a word delhi, now i am comparing it with name in dictionary above. when it hits i want to retrieve it's id.</p>
  <pre><code>if hay == delhi:
     ga = # retrieve delhi's id
  </code></pre>