I've use http://www.aspjson.com/ for using Classic ASP with JSON.
I downloaded the code from the site above, and have it as an include file on my page:
<!--#INCLUDE file="../dist/asp/aspJSON.asp" -->
Then I can parse through the JSON response and assign variables to it.
I've used it mainly for sending emails using the Mandrill Email API.
The API sends the response in JSON format.
Example response:
[
{
"email": "recipient.email@example.com",
"status": "sent",
"reject_reason": "hard-bounce",
"_id": "abc123abc123abc123abc123abc123"
}
]
Send data to Mandrill...
vurl = "https://mandrillapp.com/api/1.0/messages/send.json"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlhttp.open "POST", vurl, false
xmlhttp.setRequestHeader "Content-type","application/json"
xmlhttp.setRequestHeader "Accept","application/json"
'send JSON data to the API
xmlhttp.send oJSON.JSONoutput()
Mandrill then sends a JSON response - e.g.
[
{
"email": "recipient.email@example.com",
"status": "sent",
"reject_reason": "hard-bounce",
"_id": "abc123abc123abc123abc123abc123"
}
]
I can then process it using:
'process the response JSON data
vAnswer = xmlhttp.responseText
I have to remove the square brackets from the start and end of the JSON response:
vAnswer = replace(vAnswer,"[","")
vAnswer = replace(vAnswer,"]","")
And then do stuff with the data:
'load the incoming JSON data using aspJSON
Set oJSON = New aspJSON
'Load JSON string
oJSON.loadJSON(vAnswer)
'set variable values from the incoming data
json_email = ap(oJSON.data("email"))
json_status = ap(oJSON.data("status"))
json_reject_reason = ap(oJSON.data("reject_reason"))
json_id = ap(oJSON.data("_id"))
How you would do it would depend on the structure of the JSON data you are working with.