标题:请教JSON,用的是foxjson.dll,字符数组取值报错!
取消只看楼主
laibinhua
Rank: 2
等 级:论坛游民
威 望:1
帖 子:205
专家分:31
注 册:2010-12-23
结帖率:56.36%
已结贴  问题点数:20 回复次数:5 
请教JSON,用的是foxjson.dll,字符数组取值报错!
请教大佬:
原报文:
{"errcode":0,"errmsg":"ok","chat_info":{"owner":"0250452735598104","showHistoryType":0,"chatid":"chateca5eb08b7f98f17f5f63b2f731b954a","validationType":0,"useridlist":["01062505372440241082","31192441281231555","0250452735598104"],"icon":"@lALPDf0i0cmB28TNAljNAlg","openConversationId":"cidtYlM6oBqlSljhqpEIX8KRQ==","searchable":0,"chatBannedType":0,"managementType":0,"mentionAllAuthority":0,"conversationTag":2,"name":"测试001","status":1}}
使用过程:
ltype=oJson.item("chat_info").item("name").value  &&可以正常取到值
ltype=oJson.item("chat_info").item("useridlist").value &&无法正常取到值,请教这里如何取?
搜索更多相关主题的帖子: dll 取值 字符 报错 item 
2021-12-06 10:39
laibinhua
Rank: 2
等 级:论坛游民
威 望:1
帖 子:205
专家分:31
注 册:2010-12-23
得分:0 
回复 3楼 吹水佬
大佬,是数组,要怎么改一下呢?
2021-12-06 11:14
laibinhua
Rank: 2
等 级:论坛游民
威 望:1
帖 子:205
专家分:31
注 册:2010-12-23
得分:0 
回复 2楼 foxfans
谢谢你的回复,你的方法很不错!
2021-12-06 11:15
laibinhua
Rank: 2
等 级:论坛游民
威 望:1
帖 子:205
专家分:31
注 册:2010-12-23
得分:0 
回复 2楼 foxfans
老师:用这个方法,又碰到个问题:
原始报文:
{"errcode":0,"errmsg":"ok","result":{"has_more":false,"list":[{"active":true,"admin":true,"avatar":"","boss":false,"dept_id_list":[1],"dept_order":176342269632077512,"exclusive_account":false,"hide_mobile":false,"leader":false,"mobile":"1378223750","name":"张三","state_code":"86","unionid":"7Az7l9unGiPeiPeliSJiPMwSxwiEiE","userid":"31192441281231555"},{"active":true,"admin":true,"avatar":"","boss":false,"dept_id_list":[1],"dept_order":176287327676115512,"exclusive_account":false,"hide_mobile":false,"leader":false,"mobile":"13333332616","name":"李四","state_code":"86","unionid":"3yp6KVDiiLaEiE","userid":"0250452735598104"},{"active":true,"admin":false,"avatar":"","boss":false,"dept_id_list":[1],"dept_order":176279123423347512,"exclusive_account":false,"hide_mobile":false,"leader":false,"mobile":"13122255731","name":"王五","state_code":"86","unionid":"nxiPrUYqlECM28QouwDa26QiEiE","userid":"01062505372440241082"}]},"request_id":"5nmgrf45ars4"}
我用你的方法,这样取所有人的姓名报错:
m.oJs=CREATEOBJECT("MSScriptControl.ScriptControl")
m.oJs.Language="jscript"
m.oJs.addCode(m.cJsonStr)   
m.oSon=m.oJs.CodeObject.json.result.list.name
FOR EACH m.SubItem IN m.oSon
?m.SubItem &&这大概就是你要的值了
ENDFOR
RELEASE m.oJs
2021-12-06 14:11
laibinhua
Rank: 2
等 级:论坛游民
威 望:1
帖 子:205
专家分:31
注 册:2010-12-23
得分:0 
回复 8楼 吹水佬
谢谢大佬,你这样对!
2021-12-06 14:25
laibinhua
Rank: 2
等 级:论坛游民
威 望:1
帖 子:205
专家分:31
注 册:2010-12-23
得分:0 
回复 2楼 foxfans
m.oSon=m.oJs.CodeObject.json.result
FOR EACH m.SubItem IN m.oSon
?m.SubItem &&这大概就是你要的值了
ENDFOR

用什么方法可以知道  m.oSon 里有几个Item记录 , 我这样写不对:
m.oSon.count()
m.oSon.items.count()

[此贴子已经被作者于2022-11-5 16:16编辑过]

2022-11-05 16:13



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-507770-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.385733 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved