1

i'm trying to do an do while with this code:

    <%
       dim i
       i=0
        Do While i <  19
        response.Write "<th>" & data1.standing.[i].position & "</th>"   
           i=i+1   
        Loop 
        %>

this come from a api call, is a json response, and data1.standing.[in].position is the way to extract the position of a soccer team: url :link
but this section [i] don't iterate.

any clue?

sorry for the bad english.

Mtac
  • 63
  • 5
  • the problen is the square brackets [ ] – Mtac May 10 '18 at 06:09
  • Curly brackets around the counter??: (i) – David May 10 '18 at 14:31
  • don't work, `[ ]` this remove the format of variables like `i` between the square parents – Mtac May 11 '18 at 01:13
  • Can you try data1.standing[i].position? (without the dot before the first square bracket)? Please note that vbscript can read jscript arrays, but there are restrictions in types. I have mixed vbscript and jscript before, but sometimes you need helper functions in jscript so that vbscript can use them like here: https://stackoverflow.com/questions/28072209/javascript-array-to-vbscript/32325928#32325928 – Erik Oosterwaal May 11 '18 at 08:51

1 Answers1

0

Looking at your code I suspect you're actually trying to use JScript, not VBScript as I assumed.

An example of how to gather the JSON string into a variable in VBScript:

dim objXML
Set objXML = Server.CreateObject("MSXML2.ServerXMLHTTP")
objXML.open "GET", "http://api.football-    data.org/v1/competitions/398/leagueTable", False
objXML.send

Response.Write objXML.responseText

Take a look at this post for an excellent example of how to do what you're looking for. Any good libraries for parsing JSON in Classic ASP?

You can use my code to GET the string, then the link to parse and use it.

Jacob M.
  • 699
  • 1
  • 9
  • 17
  • this come from a api call, is a json response, and `data1.standing.[in].position` is the way to extract the position of a soccer team: url :[link](http://api.football-data.org/v1/competitions/398/leagueTable) – Mtac May 11 '18 at 01:05
  • I don't think you understood what I was asking. To simplify a bit, ASP Classic does not have a way to turn JSON into an object as you're displayed in your code. From your response, I suspect your example is actually JScript code and not ASP Classic. I'll throw together a new answer brb. – Jacob M. May 11 '18 at 03:11