title: Looping through JSON using ASPJSON
body: <p>I am using Classic ASP and ASPJSON (<a href="http://www.aspjson.com/" rel="nofollow">http://www.aspjson.com/</a>) to try to loop through JSON test data returned via a Mandrill Webhook.</p>
  
  <p>This is the sample JSON data - I realise the 2nd block is the same as the first, but I need to use it since when I do this on the live system the webhook data will be returned in batches in a single JSON file / post.</p>
  
  <pre><code>{
    "event":"hard_bounce",
    "msg":{
       "ts":1365109999,
       "subject":"This an example webhook message",
       "email":"example.webhook@mandrillapp.com",
       "sender":"example.sender@mandrillapp.com",
       "tags":[
          "webhook-example"
       ],
       "state":"bounced",
       "metadata":{
          "user_id":111
       },
       "_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa",
       "_version":"exampleaaaaaaaaaaaaaaa",
       "bounce_description":"bad_mailbox",
       "bgtools_code":10,
       "diag":"smtp;550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces."
    },
    "_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa",
    "ts":1433940242
  },
  {
    "event":"hard_bounce",
    "msg":{
       "ts":1365109999,
       "subject":"This an example webhook message",
       "email":"example.webhook@mandrillapp.com",
       "sender":"example.sender@mandrillapp.com",
       "tags":[
          "webhook-example"
       ],
       "state":"bounced",
       "metadata":{
          "user_id":111
       },
       "_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa1",
       "_version":"exampleaaaaaaaaaaaaaaa",
       "bounce_description":"bad_mailbox",
       "bgtools_code":10,
       "diag":"smtp;550 5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces."
    },
    "_id":"exampleaaaaaaaaaaaaaaaaaaaaaaaaa1",
    "ts":1433940242
  }
  </code></pre>
  
  <p>In my test ASP page, I tried a simple test (I have already confirmed the JSON data is valid by saving it to a database and checking the content)</p>
  
  <pre><code>&lt;!--#INCLUDE file="aspJSON.asp" --&gt;
  str2 = &lt;POST DATA FROM MANDRILL&gt;
  Set oJSON = New aspJSON
  oJSON.loadJSON(str2)
  
  Response.Write oJSON.data("event") &amp; "&lt;hr&gt;"
  response.write "&lt;h1&gt;test&lt;/h1&gt;"
  
  For Each phonenr In oJSON.data("msg")
      Set this = oJSON.data("msg").item(phonenr)
      Response.Write _
      this.item("subject") &amp; ": " &amp; _
      this.item("diag") &amp; "&lt;br&gt;"
  Next
  </code></pre>
  
  <p>When Mandrill calls the ASP page, it returns this error:</p>
  
  <p>Description: Object not a collection : . </p>
  
  <p>For this line:
  For Each phonenr In oJSON.data("msg")</p>
  
  <p>I am stuck working out how, for each event, I can loop through it and get the attributes from "msg" and the "_id" value as well.</p>