I am using the Classic ASP "ASP JSON" class to work with JSON data on the Mandrill Email API.
This is the code I'm working on / am stuck on at the moment:
<%
Set oJSONRej = New aspJSON
With oJSONRej.data
.Add "key", KEY
.Add "email", "this@that.com"
End With
vurl = "https://mandrillapp.com/api/1.0/rejects/list.json"
set xmlhttpRej = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlhttpRej.open "POST", vurl, false
xmlhttpRej.setRequestHeader "Content-type","application/json"
xmlhttpRej.setRequestHeader "Accept","application/json"
'send JSON data to the API
xmlhttpRej.send oJSONRej.JSONoutput()
'process the response JSON data
vAnswerRej = xmlhttpRej.responseText
vAnswerRej = replace(vAnswerRej,"[","")
vAnswerRej = replace(vAnswerRej,"]","")
%>
I can't work out how to tell if the "vAnswerRej" contains data.
I have tried these options to check if the variable is empty:
if len(vAnswerRej) > 0 then....
and
if vAnswerRej <> "" then
but the length of the returned data is always zero, even if it actually does contain data because the Replace() lines after the responseText error if "vAnswerRej" is empty.
Is there a simple way to confirm if the JSON responseText contains some JSON data?
I presume it's something to do with using JSON data and that the object is not treated like a regular string variable, but I can't work out how to check if it is empty.
Any advice much appreciated.
Thanks!