This article describes how to use ASP parsing JSON string, we all know that the ASP to the JSON processing is not as simple as PHP, and there is no key value array, this may also be the reason it eventually replaced by PHP directly.
The following code is available through my test,
The code is as follows:
Dim scriptctrlfunction 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.resultEnd Functiondim Jsonjson = "{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 = NothingSet Scriptctrl = Nothing
This article is provided by topic.alibabacloud.com,
Article Address: http://www.php.cn/csharp-article-377133.html
Learn programming to topic.alibabacloud.com www.php.cn