Tricking Out Classic ASP With JSON – The Mandrill Experience

Using JSON with Classic ASP can be a tricky thing, but the developer of ASPJSON has made it very easy.  This library ( or include ) has made my life so much easier, but the instructions to get me started was somewhat raw and difficult for me to follow.

Since my original posting about  Tricking Out Classic ASP with JSON, I have had several people ask for the solution to SendGrid and Mandrill.  Both systems are very different, but the principals are similar.  I found Mandrill the easiest to implement.

The following code is the magic to it all, but this example is specific to Mandrill.

   jsonstring = ""  

   If Request.TotalBytes > 0 Then   
     Dim lngBytesCount   
     lngBytesCount = Request.TotalBytes   
     jsonstring = BytesToStr(Request.BinaryRead(lngBytesCount))   
   End If   

   Set oJSON = New aspJSON  
   'Load JSON string  
   jsonstring = replace(jsonstring, "mandrill_events=","")  
   oJSON.loadJSON(URLDecode(jsonstring))  

 ' Loop Through Records  
 for i = 0 to oJSON.data.count -1  
   str = oJSON.data(i).item("event")  
   straddress = oJSON.data(i).item("msg").item("email")  
 next  

You can download the full code sample from:  http://www.unlatched.com/sample/Mandrill%20with%20Classic%20ASP/mandrill%20aspjson%20testing.zip

I did include the ASPJSON include file so that you would get the complete solution; but you should ensure you have the latest once you have my example working.  Goto ASPJSON to get the latest library.

Tricking Out Classic ASP With JSON – Updated

Amendment:  Some people have had trouble downloading the aspJSON.asp file from the site where I had found it.  You can download the file from me.

Amendment:: Some people were asking for a solution to Mandrill and SendGrid. Both solutions are similar and therefore I selected one to publish. You can contact me if you would like more. See the following: Part II – The Mandrill Experience

Sometimes you get trapped in using languages you don’t prefer. I often find my self playing in the bowels of Classic ASP. Now Classic ASP is not bad, but it is a little outdated and has not really been built upon for a few years. I have recently built some new tools in Classic ASP to compliment an existing tool set; however, I tricked out ASP with JSON.

To do this I had found a wonderful import file written by Gerrit van Kuipers. You can download a copy of the file from: www.aspjson.com. Yes it is version 1.0, but I have not found an issue with it yet.

Continue reading Tricking Out Classic ASP With JSON – Updated