title: Python: How to check if JSON item exists?
body: <pre><code>{
    "data": [
      {
        "name": "john",
        "information": {
          "age": "20",
          "height": "6'0",
          "fav_quote": "age is just a number",
          "sports": [
            "soccer",
            "basketball",
            "baseball",
            "football",
            "hockey"
          ], 
  
          ...
  
        }
      }
    ]
  }
  </code></pre>
  
  <p>If I get this information with <code>info = json.loads(myjsonthatsabove)</code> how do I check if 'age' exists, because the information in the json can be different and not always have that. How can I check if <code>sports[3]</code> (football) exists, or find out how many items are in the sports array?</p>
  
  <pre><code>if 'age' in info['data'][0]['information']:
      //code
  </code></pre>
  
  <p>works to check if age is there, but is this checking all of ['information'], so for example if ['fav_quote'] had 'age' in it it would work? How can I check this information?</p>