title: Search and return values from nested dict (or from json file)
body: <p>I have nested dictionaries created by importing json file (json.load), looking like this:</p>
  <pre><code>&quot;124&quot;: {
      &quot;vacancy_title&quot;: &quot;Оператор линии&quot;,
      &quot;vacancy_employer&quot;: &quot;Промышленное  производство, Жуков&quot;,
      &quot;vacancy_url&quot;: &quot;https://www.rekadro.ru/vacancies/124/&quot;,
      &quot;vacancy_city&quot;: &quot;Обнинск&quot;
  },
  
  &quot;125&quot;: {
      &quot;vacancy_title&quot;: &quot;Консультант по подбору персонала&quot;,
      &quot;vacancy_employer&quot;: &quot;Кадровая компания \&quot;Рекадро\&quot;, работа удаленно&quot;,
      &quot;vacancy_url&quot;: &quot;https://www.rekadro.ru/vacancies/125/&quot;,
      &quot;vacancy_city&quot;: &quot;Россия&quot;
  },
  </code></pre>
  <p>The JSON file is huge, and I need to find all the pieces of data where <code>vacancy_city == &quot;somestring&quot;</code>, <code>vacancy_city</code> is not a unique value.</p>
  <p>What i try, is to do something like this:</p>
  <pre><code>import json
  
  
  with open(&quot;vacancies_dict.json&quot;) as file:
      vacancies_dict = json.load(file)
  
  city = &quot;Санкт-Петербург&quot;
  
  for a,b in vacancies_dict.items():  #accessing keys
      for k in b.values():
          if k == city:
              for k, v in sorted(b.items())[-5:]:
                  vacancy = f&quot;{v['vacancy_title']}\n&quot;\
                      f&quot;{v['vacancy_employer']}\n&quot;\
                      f&quot;{v['vacancy_city']}\n&quot;\
                      f&quot;{(v['vacancy_title'],v['vacancy_url'])}\n&quot;
  </code></pre>
  <p>It doesnt work, I understand that I do it the wrong way, I also know that masters can write a singleton with a regex (which sounds to me like magic).
  Asking to help with finding a way to reach the result in a longer, but easier for &quot;non programmer&quot; understanding.</p>
  <p>P.S. I was also looking to import from JSON directly the needed piece of data, using JSONSelect package, but it's deprecated (<a href="https://github.com/mwhooker/jsonselect" rel="nofollow noreferrer">https://github.com/mwhooker/jsonselect</a>)</p>