title: Looping through Youtube Search JSON response
body: <p>I am using ASPJson for working with ASP and JSON (it used to be hosted here a while ago <a href="http://www.aspjson.com/" rel="nofollow noreferrer">http://www.aspjson.com/</a> but that site is no longer live, but the code I got from that site is here: <a href="https://pastebin.com/LJzikNAT" rel="nofollow noreferrer">https://pastebin.com/LJzikNAT</a>)</p>
  
  <p>This is my call to Youtube - example:</p>
  
  <pre class="lang-none prettyprint-override"><code>https://www.googleapis.com/youtube/v3/search?part=id&amp;q=london&amp;type=video&amp;key=[my_key]
  </code></pre>
  
  <p>That returns this JSON data:</p>
  
  <pre><code>{
   "kind": "youtube#searchListResponse",
   "etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/o9DTjpevDXudxmhkLef6i-kAnRE\"",
   "nextPageToken": "CAUQAA",
   "regionCode": "GB",
   "pageInfo": {
    "totalResults": 1000000,
    "resultsPerPage": 5
   },
   "items": [
    {
     "kind": "youtube#searchResult",
     "etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/Qq093B1iIdU7htjV5jYf2Erqxgk\"",
     "id": {
      "kind": "youtube#video",
      "videoId": "5DniDm9epIY"
     }
    },
    {
     "kind": "youtube#searchResult",
     "etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/gbHSPn7IT-2OJG19vQZzKKTbG1s\"",
     "id": {
      "kind": "youtube#video",
      "videoId": "Zlu542Tx8Fc"
     }
    },
    {
     "kind": "youtube#searchResult",
     "etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/KQSQBNAk2ArZd_XrpDOIfiMT0XM\"",
     "id": {
      "kind": "youtube#video",
      "videoId": "2tufxwCyrmE"
     }
    },
    {
     "kind": "youtube#searchResult",
     "etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/wrbmiGkrH9v_QvtNpoIurXH9YQc\"",
     "id": {
      "kind": "youtube#video",
      "videoId": "1XU8AOZ0Inw"
     }
    },
    {
     "kind": "youtube#searchResult",
     "etag": "\"m2yskBQFythfE4irbTIeOgYYfBU/2sdAsprKoDKIt8mNVYd8prR8uVA\"",
     "id": {
      "kind": "youtube#video",
      "videoId": "vUO6kYLb6As"
     }
    }
   ]
  }
  </code></pre>
  
  <p>This is my ASP code to try and loop through the results:</p>
  
  <pre class="lang-vb prettyprint-override"><code>&lt;!--#INCLUDE file="../dist/asp/c.asp" --&gt;
  &lt;!--#INCLUDE file="../dist/asp/aspJSON.asp" --&gt;
  &lt;%
  my_api = "my_key"
  sendstring1 = "https://www.googleapis.com/youtube/v3/search?part=id&amp;q=chester&amp;type=video&amp;key="&amp;my_api&amp;""
  Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
  objXML.Open "GET", sendstring1 , false
  objXML.Send()
  
  BackFromGoogle1 = objXML.responseText
  
  Set oJSON = New aspJSON
  oJSON.loadJSON(BackFromGoogle1)
  
  For Each result In oJSON.data("items")
      Set this = oJSON.data("items").item(thingy)
      var_id = this.item("id").item("videoId")
      embed_code = "&lt;iframe width='800' height='450' src='https://www.youtube.com/embed/"&amp;var_id&amp;"?rel=0&amp;amp;wmode=opaque' frameborder='0' allowfullscreen&gt;&lt;/iframe&gt;"
      response.write embed_code   
  Next
  %&gt;
  </code></pre>
  
  <p>The trouble is that as I loop through it, the ID returned in the <code>var_id</code> variable is always <code>5DniDm9epIY</code>, which is the ID of the first video - it doesn't seem to be changing each time through the loop, and I'm not sure why?</p>
  
  <p>The <code>var_id</code> is displayed 5 times, so the code can see that there are 5 notes in the "items" collection, but it doesn't appear to go to the next node each time through the loop.</p>