|
1.解析 JSON
下面的简单示例试图说明如何使用 ASP(vbscript版)解析JSON。
- dim jsonText
- jsonText = _
- "{" & vbcrlf & _
- " ""num"" : 42," & vbcrlf & _
- " ""lst"" : [""foo"" , ""bar"", ""baz""]," & vbcrlf & _
- " ""obj"" : {""hello"": ""World""}" & vbcrlf & _
- "}"
- Response.Write("Json字符串:")
- Response.Write("<p>********************</p>")
- Response.Write(jsonText)
- Set scrContr = server.CreateObject("MSScriptControl.ScriptControl")
- scrContr.language = "JScript"
-
- set parsed = scrContr.eval("(" & jsonText & ")")
-
- Response.Write("<p>解析如下:</p>")
- Response.Write("num = " & parsed.num )
- Response.Write("obj.hello = " & parsed.obj.hello)
-
-
-
- %>
复制代码 |
|