ASP read JSON list solution idea

Source: Internet
Author: User

How to use the ASP program to read the URL and then use the program to read the results, the complete ASP program

------Solution--------------------
So it's not a hair? Knowledge has become an array and the methods are almost http://bbs.csdn.net/topics/390776429

<script runat= "Server" language= "JScript" >

function Getjson (v) {return eval (' + V + ') ');


function ToArray (a) {//json object array format string


var dic = Server.CreateObject ("Scripting.Dictionary");


for (var i = 0; i &lt; a.length; i++) {


var obj = Server.CreateObject ("Scripting.Dictionary");


for (x in a[i]) obj. ADD (x, a[i][x]);


DiC. ADD (i, obj);


        }


return dic;


    }


&lt;/script&gt;


&lt;%


'==================================================


' generates content from the 2 data stream


'==================================================


Function bytestobstr (strbody,codebase)


Dim obj


set Obj=server.createobject ("ADODB.stream")


obj. Type=1


obj. Mode=3


obj. Open


obj. Write strbody


obj. Position=0


obj. type=2


obj. Charset=codebase


Bytestobstr=obj. ReadText


obj. Close


Set obj=nothing


End Function


function downpage (URL)


set Xhr=server. CreateObject ("Microsoft.XMLHTTP")


Xhr.open "Get", Url,false


Xhr.send


downpage=bytestobstr (xhr.responsebody, "gb2312") ' pay attention to the code of your page, it is impossible to make garbled


End Function





   








' s change to microsoft.xmlhttp dynamic access


' S=downpage ("http://www.xxx.com/?no=710000")


S= "{" "ResultCode" ":" "", "" Reason "": "" Return SUCCESSD "", "" Result "": [{"" id "": "" 1 "", "" Province "" "" "," "" " "": "Xi ' an", "" Area "": "" Baqiao District "", "" Address "": "" Di Zhai Zhen Nanzhai village ""},{"" id "": "" 2 "", "" Province "": "" Shaanxi Province "," "City" ":" "Xi ' an", "" "" Area "": "" Baqiao District "", "" Address "": "" Di Pancun ""}

, {"" id "": "" 3 "," "," "Province" ":" "Shaanxi Province" "," "City" ":" "Xi ' an", "" Area "": "" Baqiao District "", "" Address "": "" Di Wu Fang Village ""}, "" Error_code "" : 0} "
Set O=getjson (s)
If o.resultcode= "then"
Set Result=toarray (O.result)

For I=0 to Result.count-1
Response. Write result (i) ("Province") & "-" &result (i) ("Address") & "<br/>"
Next

Set result=nothing
End If
Set o=nothing
%>

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.