BRIANBOY12
10-31-2010, 11:53 PM
I am trying to parse an xmlhttp.responseText which is returned in JSON format. I specifically want to get the "value" of the "distance:text" keys ... i.e. "13.7 mi, 0.2 mi, etc". I'm not very familiar with server-side scripting. Most of my googling seems to indicate this should be straight forward and easy with the returnedText being in JSON format, but I can't seem to find an example of this using server-side scripting to parse the responseText. The server script below works fine, but it doesn't accomplish what I really want. Below the server script is a snippet of the responseText.
<%
url = "http://maps.google.com/?output=html&saddr='san leandro,ca'&daddr='san mateo,ca'"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.send ""
myString = "text"
if instr(xmlhttp.responseText,myString)>0 then
response.write "found it !!"
else
response.write xmlhttp.responseText
end if
set xmlhttp = nothing
%>
The following is a snippet of the responseText:
"distance": {
"value": 22021,
"text": "13.7 mi"
}
}, {
"travel_mode": "DRIVING",
"start_location": {
"lat": 37.5517600,
"lng": -122.3098200
},
"end_location": {
"lat": 37.5510600,
"lng": -122.3127400
},
"distance": {
"value": 284,
"text": "0.2 mi"
}
}, {
"travel_mode": "DRIVING",
"start_location": {
"lat": 37.5510600,
"lng": -122.3127400
},
"end_location": {
"lat": 37.5628300,
"lng": -122.3257500
},
<%
url = "http://maps.google.com/?output=html&saddr='san leandro,ca'&daddr='san mateo,ca'"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.send ""
myString = "text"
if instr(xmlhttp.responseText,myString)>0 then
response.write "found it !!"
else
response.write xmlhttp.responseText
end if
set xmlhttp = nothing
%>
The following is a snippet of the responseText:
"distance": {
"value": 22021,
"text": "13.7 mi"
}
}, {
"travel_mode": "DRIVING",
"start_location": {
"lat": 37.5517600,
"lng": -122.3098200
},
"end_location": {
"lat": 37.5510600,
"lng": -122.3127400
},
"distance": {
"value": 284,
"text": "0.2 mi"
}
}, {
"travel_mode": "DRIVING",
"start_location": {
"lat": 37.5510600,
"lng": -122.3127400
},
"end_location": {
"lat": 37.5628300,
"lng": -122.3257500
},