title: Checking json and displaying only available data
body: <p>I'm working on a simple website that is using a json to get data. </p>
  
  <p>The code looks like this:</p>
  
  <p>Index:</p>
  
  <pre><code>&lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /&gt;
      &lt;meta name="apple-mobile-web-app-capable" content="yes" /&gt;
      &lt;meta name="mobile-web-app-capable" content="yes" /&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&gt;
      &lt;title&gt;Linköping&lt;/title&gt;
      &lt;link type="text/css" rel="stylesheet" media="all" href="css/main.css" /&gt;
      &lt;script type="text/javascript" src="js/jquery-2.1.4.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="js/textmetrics.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
      var config = {
          // General config
          slideTime: 15*1000,
          fadeTime: 3*1000,
  
  
          // Time
          timeUpdate: 60*1000,
  
          // Names
          nameDayUrl: 'namedays.json',
          nameUpdate : 60*1000,
  
          // Events
          eventUrl: 'Idrottsevent.json',
          eventUpdate : 1*1000,
  
          // Weather
          weatherUrl: 'http://api.openweathermap.org/data/2.5/find?lat=58.41&amp;lon=15.62&amp;cnt=1&amp;units=metric&amp;appid=2de143494c0b295cca9337e1e96b00e0',
          weatherUpdate: 1800*1000
      }
      &lt;/script&gt;
  
  
  &lt;div class="slide304" id="eventSlide"&gt;
      &lt;div class="center"&gt;
          &lt;div id="gameTicker1"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="slide304" id="eventSlide"&gt;
      &lt;div class="center"&gt;
          &lt;div id="gameTicker2"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="slide304"&gt;
      &lt;div class="center"&gt;
          &lt;div id="weatherTicker"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;  
  
  &lt;script type="text/javascript"&gt;
      // Global data 
      var _names = {};
      var _events = {};
      var _games = {};
  
  $(document).ready(function() {
          // Get events
          $.ajax({
              url: config.eventUrl,
              async: true,
              cache: false,
              method: 'GET',
              success: function(result) {
                  _games = result;
                  setGame1();
                  setGame2();
  
              },
              error: function(xhr, status, error) {
                  _games = {};
              }
          });
  
  function setGame1() {
          // Select game.
          var nowDate = getTimeForEvents();
          var mm = addZero(nowDate.getMonth() + 1);
          var d = addZero(nowDate.getDate());
          var key = mm + "-" + d + "A";
          var game = (typeof _games[key] != "undefined") ? _games[key] : "";
          $('#gameTicker1').html((game == '') ? '' : game);
          setFontSizeForCurrentSlide();
          setTimeout(setGame1, config.eventUpdate);
      }
  
          function setGame2() {
          // Select game.
          var nowDate = getTimeForEvents();
          var mm = addZero(nowDate.getMonth() + 1);
          var d = addZero(nowDate.getDate());
          var key = mm + "-" + d + "B";
          var game = (typeof _games[key] != "undefined") ? _games[key] : "";
          $('#gameTicker2').html((game == '') ? '' : game);
          setFontSizeForCurrentSlide();
          setTimeout(setGame2, config.eventUpdate);
      }
  </code></pre>
  
  <p>Here is a part of the json code.</p>
  
  <pre><code>  "01-25A": "Dagens match:&lt;br /&gt;TEST Linköpings VC-Hylte Halmstad&lt;br /&gt;15:00 Linköpings sporthall",
  </code></pre>
  
  <p>The code checks the day and month and the letter which is attached to each game that day. If there are two games on one day, then game one has "A" and game 2 has "B" etc. </p>
  
  <p>Right now the website slides through every game in the JavaScript (SetGame1, SetGame2). It displays a dark slide after the displaying the first game because there is only one game on the json. What I want it to do is to check and make sure that it only slides through games that are available and skip the the games that are not available on the json. If there is only one game on that json then it should not try to display GameSet2.</p>
  
  <p>Can anyone help me with this? </p>
  
  <p><strong>UPDATE:</strong>
  Complete Json:</p>
  
  <pre><code>{
   "12-27": [
                                "Dagens match:&lt;br /&gt;KFUM Linköping-Falcao FC Stockholm&lt;br /&gt;13:00 Linköpings Sporthall"                                                       
   ],
  
  
   "12-28": [
                                "Dagens match:&lt;br /&gt;LHC-Rögle BK&lt;br /&gt;19:00 SAAB ARENA"
   ],
  
  
   "12-30": [
                                "Dagens match:&lt;br /&gt;LHC-Örebro Hockey&lt;br /&gt;19:00 SAAB ARENA"                             ],
  
  
  
   "01-02": [
                                "Dagens match:&lt;br /&gt;Linköping Innebandy-Malmö FBC&lt;br /&gt;14:10 SAAB ARENA",
  "Dagens match:&lt;br /&gt;Linköping Innebandy-Växjö IBK&lt;br /&gt;17:10 SAAB ARENA"
   ],
  
  
  
   "01-08": [
                                "Dagens match:&lt;br /&gt;KFUM Linköping- Spartak Örebro Futsal Club&lt;br /&gt;20:00 Linköpings Sporthall"
   ],
  
  
  
   "01-10": [
                                "Dagens match:&lt;br /&gt;Linköping Innebandy-Pixbo Wallenstam IBK&lt;br /&gt;13:00 Folkungahallen",
                                "Dagens match:&lt;br /&gt;Linköping Innebandy- FC Helsingborg&lt;br /&gt;17:00 Linköpings Sporthall"
  
   ],
  
   "01-13": [
                                "Dagens match:&lt;br /&gt;Linköping Innebandy-IK Sirius IBK&lt;br /&gt;19:00 Linköpings Sporthall"
   ],
  
  
   "01-14": [
                                "Dagens match:&lt;br /&gt;LHC-Färjestads BK&lt;br /&gt;19:00 SAAB ARENA"
   ],
  
  
   "01-16": [
                                "Dagens match:&lt;br /&gt;Linköpings VC-Örkeljunga&lt;br /&gt;15:00 Linköpings Sporthall"
   ],
  
  
   "01-17": [
                                "Dagens match:&lt;br /&gt;Linköping Innebandy-IBF Falun&lt;br /&gt;13:00 Folkungahallen",
                                "Dagens match:&lt;br /&gt;RP IF-GF Kroppskultur&lt;br /&gt;13:30 Linköpings Sporthall",
                                "Dagens match:&lt;br /&gt;RP IF Linköping-HK Silwing/Troja&lt;br /&gt;16:00 Linköpings sporthall"
   ],
  
   "01-23": [
                                "Dagens match:&lt;br /&gt;Linköping VC-KFUM Eskilstuna volley&lt;br /&gt;15:00 Folkungahallen",
                                "Dagens match:&lt;br /&gt;LHC-Frölunda HC&lt;br /&gt;16:00 SAAB ARENA"
   ],
  
  
   "01-24": [
                                "Dagens match:&lt;br /&gt;Linköpings VC-Hylte Halmstad&lt;br /&gt;15:00 Linköpings sporthall"
   ],
  
  
  
   "01-25A":                     "Dagens match:&lt;br /&gt;TEST Linköpings VC-Hylte Halmstad&lt;br /&gt;15:00 Linköpings sporthall",
  
  
  
  "01-27": [
                                "Dagens match:&lt;br /&gt;Linköpings VC-Södertelge&lt;br /&gt;19:00 Linköpings sporthall"
                                                          ],
  
  
  
  "01-29": [
                                                            "Dagens match:&lt;br /&gt;Linköping Innebandy-Endre IF&lt;br /&gt;19:30 Folkungahallen",
                                                            "Dagens match:&lt;br /&gt;Linköping HC-MODO Hockey&lt;br /&gt;19:00 Stångebro Ishall"
  
                               ],
  
  "01-30": [
                                                            "Dagens match:&lt;br /&gt;LHC-HV71&lt;br /&gt;18:30:SAAB ARENA",
                                                            "Dagens match:&lt;br /&gt;Linköping VC-Sollentuna&lt;br /&gt;13:00 Folkungahallen",
                                                            "Dagens match:&lt;br /&gt;Linköping HC-Brynäs IF&lt;br /&gt;16:00 Stångebro Ishall",
                              "Dagens match:&lt;br /&gt;Linköping Innebandy-Warberg IC&lt;br /&gt;15:00 Linköpings Sporthall"
                               ],
  
  
  "01-31": [
                                                            "Dagens match:&lt;br /&gt;Linköping HC-IF Sundsvall Hockey&lt;br /&gt;12:00 Stångebro Ishall",
                                                            "Dagens match:&lt;br /&gt;RP IF Linköping-Tyresö Handboll&lt;br /&gt;13:30 Linköpings sporthall",
                                                            "Dagens match:&lt;br /&gt;RP IF Linköping-Brännans HF&lt;br /&gt;16:00 Linköpings sporthall"
                               ],
  
  
  
  "02-04": [
                                                            "Dagens match:&lt;br /&gt;LHC-MODO Hockey&lt;br /&gt;19:00 SAAB ARENA"
                               ],
  
  
  "02-13": [
                                                            "Dagens match:&lt;br /&gt;RP IF Linköping-Lidingö SK&lt;br /&gt;13:30 Linköpings sporthall",
                                                            "Dagens match:&lt;br /&gt;RP IF Linköping-HK GP&lt;br /&gt;16:00 Linköpings sporthall",
                                                            "Dagens match:&lt;br /&gt;Linköping Innebandy-IBK Dalen&lt;br /&gt;14:30 Motala Sporthall"
                               ],
  
  "02-16": [
                                                            "Dagens match:&lt;br /&gt;LHC-Skellefteå AIK&lt;br /&gt;19:00 SAAB ARENA"
                               ],
  
  "02-19": [
                                                            "Dagens match:&lt;br /&gt;Linköping Innebandy-Pixbo Wallenstam IBK&lt;br /&gt;19:00 Linköpings Sporthall"
                               ],
  
   "02-20": [
                                                            "Dagens match:&lt;br /&gt;LHC-Växjö Lakers&lt;br /&gt;16:00 SAAB ARENA",
                                                            "Dagens match:&lt;br /&gt;Linköpings VC-Västerås VBK&lt;br /&gt;15:00 Folkungahallen",
                                                            "Dagens match:&lt;br /&gt;Linköping HC-SDE HF&lt;br /&gt;12:00 Stångebro Ishall"
                               ],
  
   "02-21": [
                                                            "Dagens match:&lt;br /&gt;Linköping HC-Leksands IF&lt;br /&gt;13:00 SAAB ARENA",
                                                            "Dagens match:&lt;br /&gt;Linköping Innebandy-Rönnby Västerås IBK&lt;br /&gt;13:00 Folkungahallen"
                               ],
  
  
  
  
   "02-24": [
                                                            "Dagens match:&lt;br /&gt;Linköpings VC-Sollentuna&lt;br /&gt;19:00 Linköpings sporthall",
                                                            "Dagens match:&lt;br /&gt;LHC-Rögle BK&lt;br /&gt;19:00 SAAB ARENA"
                               ],
  
   "02-26": [
                                                            "Dagens match:&lt;br /&gt;Linköping Innebandy-Huddinge IK&lt;br /&gt;19:30 Folkungahallen"
                               ],
  
  "02-27": [
                                                            "Dagens match:&lt;br /&gt;Linköpings VC-Tierp&lt;br /&gt;15:00 Linköpings sporthall",
                                                            "Dagens match:&lt;br /&gt;RP IF Linköping-Skara HF&lt;br /&gt;13:30 Linköpings sporthall",
                                                            "Dagens match:&lt;br /&gt;LHC-Brynäs IF&lt;br /&gt;18:30 SAAB ARENA",
                              "Dagens match:&lt;br /&gt;RP IF Linköping-Mantorps IF HF&lt;br /&gt;16:00 Linköpings sporthall"
                               ],
  
  
   "03-01": [
                                                            "Dagens match:&lt;br /&gt;LHC-Örebro Hockey&lt;br /&gt;19:00 SAAB ARENA"
                               ],
  
  
  "03-05": [
                                                            "Dagens match:&lt;br /&gt;Linköpings VC-Jomala IK&lt;br /&gt;15:00 Folkungahallen",
                                                            "Dagens match:&lt;br /&gt;LHC-HV71&lt;br /&gt;16:00 SAAB ARENA",
                                                            "Dagens match:&lt;br /&gt;Linköping Innebandy-IBK Dalen&lt;br /&gt;17:15 Linköpings Sporthall"
                               ],
  
  
  
  "03-08": [
                                                            "Dagens match:&lt;br /&gt;LHC-Malmö Redhawks&lt;br /&gt;19:00 SAAB ARENA"
                               ],
  
  
  "03-09": [
                                                            "Dagens match:&lt;br /&gt;Linköpings VC-Vingåker&lt;br /&gt;19:00 Linköpings sporthall"
                               ],
  
  
  "03-19": [
                                                            "Dagens match:&lt;br /&gt;Linköpings VC-Rissne IF&lt;br /&gt;15:00 Folkungahallen",
                                                            "Dagens match:&lt;br /&gt;RP IF Linköping-Skånela IF&lt;br /&gt;17:00 Linköpings sporthall"
                               ],
  
  
  
  "03-20": [
                                                            "Dagens match:&lt;br /&gt;RP IF Linköping-Enköpings HF&lt;br /&gt;15:00 Linköpings sporthall"
                               ]
  }
  </code></pre>