-3

I'm working on an classic ASP-project and I use ASP Xtreme Evolution to parse JSon data (found here: How to access JSON data in classic ASP using json2.asp or aspjson libraries?) I tried, but I can't. how do i access this json data?

{  
   "result":[  
      {  
         "key":"2607037",
         "sts":"finished",
         "stsdetail":"Finished",
         "sname":"Ice Hockey",
         "home":{  
            "1p":"0",
            "fe":"2",
            "3p":"1",
            "2p":"1",
            "ord":"2",
            "rs":"2"
         },
         "away":{  
            "ord":"0",
            "1p":"0",
            "rs":"0",
            "2p":"0",
            "3p":"0",
            "fe":"0"
         }
      },
      {  
         "key":"2435948",
         "sts":"finished",
         "stsdetail":"Finished",
         "sname":"Soccer",
         "home":{  
            "ord":"2",
            "rs":"2",
            "fe":"2",
            "ht":"1"
         },
         "away":{  
            "ord":"0",
            "rs":"0",
            "fe":"0",
            "ht":"0"
         }
      },
      {  
         "key":"2606031",
         "sts":"cancelled",
         "stsdetail":"Cancelled",
         "sname":"Tennis"
      }
   ]
}

code:

set restaurant = oJSON.data("result")

for each itm in restaurant

    if Not IsObject(restaurant.item(itm)) then
        Response.write itm  &" : "& restaurant.item(itm) & "<br/>"
    else
    'opening
        for each dayy in restaurant.item(itm)
           Response.write dayy & ":"
                Response.write restaurant.item(itm)(dayy)

                If restaurant.item(itm)(dayy)  <> "" Then
                    Response.write " - "
                    Response.write restaurant.item(itm)(dayy) 
                End If

            Response.write "<br/>"
        next
    end if
Ted Jang
  • 55
  • 5

1 Answers1

1

you're missing the indexes in the array, try this:

for each dayy in restaurant.item(itm)
        Response.write dayy & ":"
            Response.write restaurant.item(itm)(dayy)(0) 

            If restaurant.item(itm)(dayy)(1) <> "" Then
                Response.write " - "
                Response.write restaurant.item(itm)(dayy)(1) 
            End If

        Response.write "<br/>"
    next
Josh Montgomery
  • 882
  • 5
  • 10