JSON (Object notation) I think this name is not unfamiliar to everyone, it is a lightweight data interchange format, is directly generated by the service of the statement, the client is obtained directly with the Eval method to obtain this object, so you can save parsing XML Parsing brings performance issues and compatibility issues, and is very easy to use, you can easily traverse the array and access to object properties to obtain data, its readability is also good, basically have the nature of structured data. Have to say is a good way, for example, Google Maps did not use XML to pass data, but use the JSON scheme.
Here I give you an ASP call Json example, play a role in the ...
Here is the tset.asp code fragment
<%
Dim strtest
Strtest = "{name:" "alonely" ", Age:24, email:[" "ycplxl1314@163.com" "," "ycplxl1314@gmail.com" "], family:{parents:[" " Father "", "" Mother ""],tostring:function () {return "" family member "";}}} "
Dim Objtest
Initscriptcontrol
Set objtest = Getjsonobject (strtest)
%>
<%=objTest.name%> Email address is <%=sc4json.eval ("jsonobject.email[0]")%>
Total Email address <%=objTest.email.length%>
<%
Dim father
Getjsarrayitem father, objTest.family.parents, 0
Response.Write Father
%>
Here is the jsonparse.asp code fragment
<%
Option Explicit
Dim Sc4json
Sub Initscriptcontrol
Set Sc4json = Server.CreateObject ("Msscriptcontrol.scriptcontrol")
Sc4json.language = ""
Sc4json.addcode "var itemtemp=null;function getjsarray (arr, index) {Itemtemp=arr[index];}"
End Sub
Function Getjsonobject (Strjson)
Sc4json.addcode "var jsonobject =" & Strjson
Set Getjsonobject = Sc4Json.CodeObject.jsonObject
End Function
Sub 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.itemTemp
End Sub
%>