2014-03-01 100 views
0

我如何獲得使用ASPJSON v1.17json2.asp的JSON數組。在經典ASP上解析JSON

[ 
    { 
    "id":1, 
    "children":[ 
     {"id":2}, 
     { 
     "id":7, 
     "children":[ 
      { 
      "id":8, 
      "children":[ 
       {"id":9} 
      ] 
      } 
     ] 
     } 
    ] 
    }, 
    { 
    "id":3, 
    "children":[ 
     {"id":11}, 
     {"id":12}, 
     {"id":13}, 
     {"id":14}, 
     {"id":15} 
    ] 
    }, 
    { 
    "id":4, 
    "children":[ 
     {"id":16}, 
     {"id":17}, 
     {"id":18} 
    ] 
    }, 
    { 
    "id":5, 
    "children":[ 
     {"id":19}, 
     {"id":20} 
    ] 
    }, 
    {"id":6} 
] 

如何迭代循環中的每個成員?

+0

檢查以下站點:http://www.aspjson.com – stare

回答

0

我已經嘗試過使用json的vbs庫,並且我得出結論,當您處理json時,使用js作爲您的腳本語言要容易得多。我說那個人討厭js(無論是服務器端還是客戶端),並且通常會盡可能地避免使用它。

反正 - 一個很簡單的例子

<%@language="javascript"%> 
<!DOCTYPE html> 
<html> 
<body> 
<h2>JSON ASP Javascript example</h2> 
<% 
var cars = [{name:'Aston Martin', colour:'Blue'}, {name:'Jaguar', colour:'Silver'}, {name:'Bentley', colour:'Green'}]; 
for (i in cars) 
{ %> 
    <%=(cars[i].name) %>, <%=(cars[i].colour) %> <br /> 
<% } %> 

</body> 
</html>