下面代码经本人测试可用,
代码以下:
Dim scriptCtrl Function parseJSON(str) If Not IsObject(scriptCtrl) Then Set scriptCtrl = Server.CreateObject("MSScriptControl.ScriptControl") scriptCtrl.Language = "JScript" scriptCtrl.AddCode "Array.prototype.get = function(x) { return this[x]; }; var result = null;" End If scriptCtrl.ExecuteStatement "result = " & str & ";" Set parseJSON = scriptCtrl.CodeObject.result End Function Dim json json = "{a:""aaa"", b:{ name:""bb"", value:""text"" }, c:[""item0"", ""item1"", ""item2""]}" Set obj = parseJSON(json) Response.Write obj.a & "<br />" Response.Write obj.b.name & "<br />" Response.Write obj.c.length & "<br />" Response.Write obj.c.get(0) & "<br />" Set obj = Nothing Set scriptCtrl = Nothing
本文由ki4网供应,
文章地点:http://www.ki4.cn/csharp-article-377133.html
学编程就来ki4网 www.ki4.cn
以上就是asp怎样剖析json字符串并转化为asp对象的细致内容,更多请关注ki4网别的相干文章!