How ASP parses a JSON string and translates it into an ASP object

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.