Home > Web Front-end > JS Tutorial > body text

Detailed explanation of steps for processing json data in asp

php中世界最好的语言
Release: 2018-04-25 14:01:02
Original
3650 people have browsed it

This time I will bring you a detailed explanation of the steps for asp to process json data. What are the precautions for asp to process json data? . The following is a practical case, let's take a look.

Can ASP also process JSON data? Haha, I just saw an article written by a brother on the Pjblog forum. I haven’t tested it, but it must be possible in theory~ It’s too late, I won’t test it.

It was too troublesome to process JSON in the past. The output was okay, just loop but parsing was really a headache. So when I encounter this kind of API problem, it is usually XML processing, which I don't like very much and is very troublesome.

<%
Dim sc4Json 
Sub InitScriptControl
Set sc4Json = Server.CreateObject("MSScriptControl.ScriptControl")
  sc4Json.Language = "JavaScript"
  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
  objDest = sc4Json.CodeObject.itemTemp
End Sub
 
Dim strTest
strTest = "{name:""alonely"", age:24, email:[""ycplxl1314@163.com"",""ycplxl1314@gmail.com""], family:{parents:[""父亲"",""母亲""],toString:function(){return ""家庭成员"";}}}"
Dim objTest
Call InitScriptControl
Set objTest = getJSONObject(strTest)
%>
<%=objTest.name%>的邮件地址是< %=sc4Json.Eval("jsonObject.email[0]")%><br />共有邮件地址< %=objTest.email.length%>个<br />
<%
Dim father
getJSArrayItem father, objTest.family.parents, 0
Response.Write father
%>
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

Comprehensive list of PHP JSON operation methods

Detailed explanation of the steps to convert Json objects and strings to each other

The above is the detailed content of Detailed explanation of steps for processing json data in asp. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!