[已解决]关于javascript解析json,为啥字符串无法提取呢?
本帖最后由 bihex 于 2015-2-13 05:04 编辑又可以运行了真奇怪,下面的代码为啥只能提取数字,字符串都无法提取;~ #AutoIt3Wrapper_UseX64=n
$json= '"data" : {"info" : [{ "age" : 30,"birth" : 19851020,"name" : "张三", "pic" : "http://...namepic.jpg","weight" : 68.5 }]}, "ok" : true'
MsgBox(4096, "", $json&@CRLF)
$oMSSC = ObjCreate('ScriptControl')
$oMSSC.Language = 'JavaScript'
$oMSSC.AddCode('var ParseJson = {' & $json & '};')
$age = $oMSSC.Eval('ParseJson.data.info.age');age
$birth = $oMSSC.Eval('ParseJson.data.info.birth');birth
$name=$oMSSC.Eval('ParseJson.data.info.name');name
$weight=$oMSSC.Eval('ParseJson.data.info.weight');weight
$pic=$oMSSC.Eval('ParseJson.data.info.pic');pic
MsgBox(4096,'' ,'age:'& $age&@CRLF&'birth:'& $birth&@CRLF&'name:'& $name&@CRLF& 'weight:'& $weight&@CRLF&'pic:'& $pic) json好像AEN上有专门的udf,你去看看。 UDF :
http://www.autoitscript.com/forum/topic/104150-json-udf-library-fully-rfc4627-compliant/
页:
[1]