SoFunction
Updated on 2025-03-04

ASP implementation code for processing JSON data

ASP can also process JSON data? Haha, I just saw an article written by a brother on the Pjblog forum. There was no test, but theoretically it must be possible~ It's too late, no test.

It was too troublesome to deal with JSON in the past, and the output was okay, just loop it up, and parsing was really a headache. So when encountering this kind of problem, API problems are usually handled in XML. I don’t like it very much, which is very troublesome.

<%
Dim sc4Json 
Sub InitScriptControl
Set sc4Json = ("")
   = "JavaScript"
   "var itemTemp=null;function getJSArray(arr, index){itemTemp=arr[index];}"
End Sub 
 
Function getJSONObject(strJSON)
   "var jsonObject = " & strJSON
  Set getJSONObject = 
End Function 
 
Sub getJSArrayItem(objDest,objJSArray,index)
  On Error Resume Next
   "getJSArray",objJSArray, index
  Set objDest = 
  If =0 Then Exit Sub
  objDest = 
End Sub
 
Dim strTest
strTest = "{name:""alonely"", age:24, email:[""ycplxl1314@"",""ycplxl1314@""], family:{parents:[""Father"",""Mother""],toString:function(){return ""Family Member"";}}}"
Dim objTest
Call InitScriptControl
Set objTest = getJSONObject(strTest)
%>
<%=%>The email address is< %=("[0]")%><br />A total of email addresses< %=%>indivual<br />
<%
Dim father
getJSArrayItem father, , 0
 father
%>

More articles related to ASP processing JSON can be read on.