0

I am having trouble finding a good way to parse the return I'm getting from XMLHTTP. The return is JSON.

ASP Code used to GET JSON:

<%@ Language=VBScript %>
<%
Set xmlhttp = CreateObject("Msxml2.ServerXMLHTTP.6.0")
xmlhttp.open "GET", "http://someip:8080/Publisher/Titles/Paging/0,0,tc?output=json", 0
xmlhttp.send ""
Response.AddHeader "Content-Type", "application/json;charset=UTF-8"
Response.Charset = "UTF-8"
pageReturn = xmlhttp.responseText

Set xmlhttp = Nothing 
response.write pageReturn
%>

Returned JSON

{
 "Titles": {
  "resultCount": 37886,
  "moreResources": true
 }
}

I need to display just the value of "resultCount" to the screen. Any help would be greatly appreciated.

1 Answer 1

3

You can look at aspjson for handling JSON with VBScript

http://code.google.com/p/aspjson/

You can also use Javascript as your classic asp server side scripting language, which would involve you rewriting your server http request in Javascript, but it would make the json part of the page much easier.

You can even use VBS and JS in the same page, eg

<%@ Language=javascript %>

<script language="VBScript" runat="server">
Set xmlhttp = CreateObject("Msxml2.ServerXMLHTTP.6.0")
xmlhttp.open "GET", "http://someip:8080/Publisher/Titles/Paging/0,0,tc?output=json", 0
xmlhttp.send ""
Response.AddHeader "Content-Type", "application/json;charset=UTF-8"
Response.Charset = "UTF-8"
pageReturn = xmlhttp.responseText    
Set xmlhttp = Nothing     
</script>

<% var resultcount = pageReturn.Titles.resultCount;
   var moreresources = pageReturn.Titles.moreResources;
%>


<html>
<body>

<%=resultcount%>, <%=moreresources%>
</body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.