Dim? scriptCtrl
Function? Parsison
What if? Isn't it? IsObject(scriptCtrl)? then
Settings? ScriptCtrl = server. CreateObject("MSScriptControl。 ScriptControl”)
scriptCtrl。 Language="JScript "
scriptCtrl。 AddCode? " array . prototype . get = function(x){ return? This [x]; }; var? Result = null "
End? if
scriptCtrl。 Execute statement? "The result =? & amp? json? & amp? ";"
Settings? parseJSON=scriptCtrl。 Code object. Results
End? function
Function? chkJSON(s)
scriptCtrl。 Execute statement? “var? Sxcz= (Results & What type? result=='object ')? ('"? & amp? s? & amp?" ? Are you online? Results): False; "
chkJSON=scriptCtrl。 CodeObject.sxcz
End? function
%> the first function parseJSON is used to parse JSON strings into objects, and the usage is as follows:
& lt%
JSON = " { XXX: 1 1 1,yyy:{zzz:222,aaa:'abc ',zzz:'qwe'},qqq:[{sss: 123,rrr:456},{sss:333,rrr:678}]} "
Settings? objJSON=parseJSON(JSON)
Response. Write? objJSON.xxx? & amp? “& ltbr >;
Response. Write? objJSON.yyy.aaa? & amp? “& ltbr >;
Response. Write? objJSON.qqq(0)。 sss? & amp? “& ltbr >;
%> The second function chkJSON is used to detect whether there is an attribute in JSON. Because there are differences between objects in VBScript and JScript, it will be wrong to directly use attributes that do not exist in VBScript (JScript does not), so if you are not sure whether an attribute exists in JSON, you'd better use this function to check it first. Note that you must use the first function before you can use this function! Usage is as follows:
& lt%
What if? ChkJSON ("hmm")? then what Response. Write? ObjJSON, yeah
% & gt