ASP JSON: Object not a collection

前端 未结 2 1900
情歌与酒
情歌与酒 2020-12-04 03:55

How should I retrieve PitcherID from this JSON? I am using the class from http://aspjson.com.

JSON

[
 {
  \"PitcherID\": \"456068\"
         


        
2条回答
  •  Happy的楠姐
    2020-12-04 04:25

    In my experience it's far easier to just use JScript as your server side scripting language than to use the aspjson class. You could render your JSON object as follows

    <%@language="javascript"%>
    
    
    
    
    
        <%
        var oJSON =[
         {
          "PitcherID": "456068"
         },
         {
          "PitcherID": "431148"
         }
        ]
        for (i in oJSON)
        { 
         Response.write((oJSON[i].PitcherID) + "
    "); } %>

    I realise that this may cause problems if the json processing is only part of a page and the rest of it uses VBScript, however you can execute server side JS in what is otherwise a VBS page by using <% Response.write strout %>

提交回复
热议问题