JSON (JavaScript Object Notation) is a lightweight data exchange format that is used by the Service to directly generate JavaScript statements, after obtaining the object, the client directly uses the eval method to obtain the object, which saves the performance and compatibility problems caused by parsing XML parsing, and is very easy to use for JavaScript, you can easily retrieve data by traversing arrays and accessing object attributes. The data is readable and basically structured data. I have to say that it is a good method. For example, Google Maps does not use XML to transmit data, but uses the JSON scheme. Here I will give you an example of using ASP to call JSON and play a leading role... below is tset. aspCodeFragment:
<! -- # Include file = "jsonparse. ASP "--> <% dim strteststrtest =" {name: "" alonely "", age: 24, email: ["" ycplxl1314@163.com "", "" ycplxl1314@gmail.com ""], family: {parents: ["father" "," "Mother" "], tostring: function () {return" "family member "";}}} "dim objtestinitscriptcontrolset objtest = getjsonobject (strtest) %> <% = objtest. the email address of name %> is <% = sc4json. eval ("jsonobject. email [0] ") %> <br> total email addresses <% = objtest. email. length %> <br> <% dim fathergetjsarrayitem father, objtest. family. parents, 0response. write Father %>
The above is the output page of the call. For the core page, please ......
The following is a jsonparse. ASP code snippet:
<% option explicitdim sc4jsonsub initscriptcontrol set sc4json = server. createobject ("msscriptcontrol. scriptcontrol ") sc4json. language = "JavaScript" sc4json. addcode "Var itemtemp = NULL; function getjsarray (ARR, index) {itemtemp = arr [Index];}" End subfunction getjsonobject (strjson) sc4json. addcode "Var jsonobject =" & strjson set getjsonobject = sc4json. codeobject. jsonobjectend functionsub getjsarrayitem (objdest, objjsarray, index) on error resume next sc4json. run "getjsarray", objjsarray, index set objdest = sc4json. codeobject. itemtemp if err. number = 0 Then exit sub end if objdest = sc4json. codeobject. itemtempend sub %>