请教 :JOSON数组中,有的组没有项目,要如何写判断是存项目
请问:因为数组中有的项目job_number没有对应的项目值,导致所有的都取不到,有什么办法可以取出有值的项目吗?代码如下:
m.cJsonStr3=[var json=]+cTxt+[;]
m.oJs3=CREATEOBJECT("MSScriptControl.ScriptControl")
m.oJs3.Language="jscript"
m.oJs3.addCode(m.cJsonStr3)
m.oSon3=m.oJs3.CodeObject.json.result.list
FOR EACH m.SubItem IN m.oSon3
&&?m.SubItem.name &&这大概就是你要的值了
l_user1=m.SubItem.name
l_mobile1=m.SubItem.mobile
l_userid=m.SubItem.userid
IF TYPE('m.SubItem.job_number')='O'
l_job_number=m.SubItem.job_number
ELSE
l_job_number=''
ENDIF
ENDFOR
附cTxt字符
{"errcode":0,"errmsg":"ok","result":{"has_more":false,"list":[{"active":true,"admin":false,"avatar":"","boss":false,"dept_id_list":[855543643],"dept_order":176231432476615512,"exclusive_account":false,"hide_mobile":false,"job_number":"A00002","leader":false,"mobile":"13780036750","name":"韩韩","state_code":"86","unionid":"ZD2NXZUWQF8zD8yVN2XiPpgiEiE","userid":"31192441281231555"},{"active":true,"admin":false,"avatar":"https:\/\/static-legacy.\/media\/lQDPM5CJnTGNdobNA4vNAvCwJTkRxR_gOoUEXnOd9cCBAA_752_907.jpg","boss":false,"dept_id_list":[855543643],"dept_order":176231432441947512,"exclusive_account":false,"hide_mobile":false,"job_number":"A00006","leader":false,"mobile":"15088432094","name":"沈李丹","state_code":"86","unionid":"3PG061tdAiP4zD8yVN2XiPpgiEiE","userid":"314637390827540275"},{"active":true,"admin":false,"avatar":"","boss":false,"dept_id_list":[855543643],"dept_order":176229535975831512,"exclusive_account":false,"hide_mobile":false,"leader":false,"mobile":"18580640160","name":"叶叶","state_code":"86","unionid":"qN8Qveaez2cOmuTqMvIuYAiEiE","userid":"6823515547694188"}]},"request_id":"15rea6o8nemk1"}
[此贴子已经被作者于2023-6-30 09:50编辑过]