asp使用Scripting.Dictionary输出JSON格式
ASP
2025-02-22 12:04
42
0
<%
Response.ContentType = "application/json"
' 创建一个JSON对象
Dim jsonResponse
Set jsonResponse = Server.CreateObject("Scripting.Dictionary")
' 添加数据到JSON对象
jsonResponse.Add "name", "张三"
jsonResponse.Add "age", 30
jsonResponse.Add "isStudent", False
' 将字典转换为JSON字符串
Dim jsonString
jsonString = "{"
Dim key
For Each key In jsonResponse.Keys
If Not IsEmpty(jsonString) Then
jsonString = jsonString & ","
End If
jsonString = jsonString & """" & key & """:" & """" & jsonResponse(key) & """"
Next
jsonString = jsonString & "}"
' 输出JSON字符串
Response.Write jsonString
%>