Results 1 to 2 of 2

Thread: Parse JSON data with vbscript

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    Parse JSON data with vbscript

    Currently I have code that will parse basic json data passed. My new issue is that if there are more then one set in the returned data I am not sure my current code works.

    I am currently using the following parser:
    https://github.com/douglascrockford/...aster/json2.js

    test.asp
    HTML Code:
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Test</title>
    <script language="javascript" runat="server" src="js/json2.js"></script>
    </head>
    <body>
    <%
    sBaseUrl = "domain.com"
    sUrl =  "https://" & sBaseUrl & "/oauth/?client_id=" & iClient_ID
    sReturnVal = GetJSONFromURL(sGetTokenUrl, "GET", "")
    
    'THIS WILL RETURN SOMETHING LIKE SO:
    '{"token":"12da6f","expires_in":300,"time_started":1311259295}
    
    Dim myJSON
    Set myJSON = JSON.parse(sReturnVal)
    sToken = myJSON.token
    Set myJSON = Nothing
    
    %>
    </body>
    </html>
    The above works but what if the data is in the following format:
    ["{\"token\":\"24bc7g\",\"expires_in\":300,\"time_started\":1311259295}",{\"token\":\"12da6f\",\"expi res_in\":300,\"time_started\":1311259296}"]

    I tried myJSON(1).token and myJSON[1].token but that didn't work.

    Thanks for any advice.

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    Re: Parse JSON data with vbscript

    Do you think a .net web service may be better?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width