asp将数组for循环输出json格式
                    
                    
                                                    
                            ASP
                             
                                                
                        2025-02-26 16:20
                         
                        
                        335
                         
                        
                        0
                         
                    
                    
                                                
                            <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Response.ContentType = "application/json"
 
' 创建模拟数据数组 
Dim cities(2)
cities(0) = Array(1, "北京", "首都")
cities(1) = Array(2, "合肥", "省会")
cities(2) = Array(3, "重庆", "直辖市")
 
Dim jsonStr, i 
jsonStr = "["
 
For i = 0 To UBound(cities)
    jsonStr = jsonStr & "{"
    jsonStr = jsonStr & """id"":" & cities(i)(0) & ","
    jsonStr = jsonStr & """title"":""" & Server.HTMLEncode(cities(i)(1)) & ""","
    jsonStr = jsonStr & """caption"":""" & Server.HTMLEncode(cities(i)(2)) & """"
    jsonStr = jsonStr & "}"
    
    If i < UBound(cities) Then 
        jsonStr = jsonStr & ","
    End If 
Next 
 
jsonStr = jsonStr & "]"
 
Response.Write jsonStr 
%>