递归火山软件开发平台

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 火山 源码 类库
查看: 9953|回复: 8
打印 上一主题 下一主题

JSON类解析,不太会用,请教下火山的前辈~

[复制链接]

3

主题

18

帖子

383

积分

中级会员

Rank: 3Rank: 3

积分
383
跳转到指定楼层
楼主
发表于 2021-3-20 15:03:04 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
{"ec":0,"errcode":0,"em":"","cache":0,"adm_num":12,"levelname":{"1":"潜水","2":"冒泡","3":"吐槽","4":"活跃","5":"话唠","6":"传说","101":"LV.1","102":"LV.2","103":"LV.3","104":"LV.4","105":"LV.5","106":"LV.6","107":"LV.7","108":"LV.8","109":"LV.9","110":"LV.10","111":"LV.11","112":"LV.12","113":"LV.13","114":"LV.14","115":"LV.15","116":"LV.16","117":"LV.17","118":"LV.18","197":"小酋长","198":"大酋长","199":"首席酋长","10":"一见倾心","11":"超凡脱俗","12":"风华绝代","13":"崭露头角","14":"金玉满堂","15":"富甲一方"},"mems":[{"uin":85901403,"role":0,"g":0,"join_time":1599222986,"last_speak_time":1599222986,"lv":{"point":0,"level":1},"card":"","tags":"-1","flag":0,"nick":"雁子","qage":16,"rm":0},{"uin":1322301722,"role":1,"g":0,"join_time":1599222832,"last_speak_time":1616221075,"lv":{"point":673,"level":6},"card":"大色秘密","tags":"-1","flag":0,"nick":"F","qage":9,"rm":0},{"uin":75602718,"role":1,"g":0,"join_time":1599656073,"last_speak_time":1616134442,"lv":{"point":459,"level":6},"card":"kyozy","tags":"-1","flag":0,"nick":"伤脑筋","qage":19,"rm":0},{"uin":570828305,"role":1,"g":0,"join_time":1599212940,"last_speak_time":1616140746,"lv":{"point":408,"level":6},"card":"创世魂","tags":"-1","flag":0,"nick":"Yobdm","qage":11,"rm":0},{"uin":309555063,"role":1,"g":-1,"join_time":1599209644,"last_speak_time":1616154104,"lv":{"point":367,"level":6},"card":"","tags":"-1","flag":0,"nick":"漠然","qage":8,"rm":0},{"uin":568415950,"role":1,"g":-1,"join_time":1599213615,"last_speak_time":1616138312,"lv":{"point":223,"level":5},"card":"Myself(hxznhf)","tags":"-1","flag":0,"nick":"Myself","qage":11,"rm":0},{"uin":35379125,"role":1,"g":0,"join_time":1599209644,"last_speak_time":1615885624,"lv":{"point":38,"level":3},"card":"项目部002","tags":"-1","flag":0,"nick":"烦烦","qage":20,"rm":0},{"uin":83318056,"role":1,"g":1,"join_time":1599209922,"last_speak_time":1616035965,"lv":{"point":26,"level":3},"card":"","tags":"-1","flag":0,"nick":"嫣然","qage":16,"rm":0},{"uin":63917125,"role":1,"g":0,"join_time":1599209644,"last_speak_time":1615162964,"lv":{"point":23,"level":3},"card":"","tags":"-1","flag":0,"nick":"精易论坛-落雪","qage":17,"rm":0},{"uin":2587018358,"role":1,"g":0,"join_time":1599209922,"last_speak_time":1614565153,"lv":{"point":14,"level":3},"card":"","tags":"-1","flag":0,"nick":"④字网名","qage":8,"rm":0},{"uin":446809585,"role":1,"g":0,"join_time":1599209644,"last_speak_time":1615020824,"lv":{"point":3,"level":2},"card":"","tags":"-1","flag":0,"nick":"精易论坛 - 冰点","qage":15,"rm":0},{"uin":979785728,"role":1,"g":-1,"join_time":1599212711,"last_speak_time":1607400099,"lv":{"point":0,"level":1},"card":"","tags":"-1","flag":0,"nick":"兔子喵","qage":12,"rm":0},{"uin":793400750,"role":1,"g":1,"join_time":1607936065,"last_speak_time":1607936065,"lv":{"point":0,"level":1},"card":"","tags":"-1","flag":0,"nick":"精易客服","qage":13,"rm":0},{"uin":370108102,"role":2,"g":0,"join_time":1603066092,"last_speak_time":1615935061,"lv":{"point":602,"level":6},"card":"","tags":"-1","flag":0,"nick":"路哥","qage":16,"rm":0},{"uin":327065266,"role":2,"g":0,"join_time":1603191884,"last_speak_time":1616222382,"lv":{"point":534,"level":6},"card":"","tags":"-1","flag":0,"nick":"謝絕ㄣ戀愛","qage":14,"rm":0},{"uin":497176980,"role":2,"g":0,"join_time":1603325142,"last_speak_time":1616221893,"lv":{"point":474,"level":6},"card":"","tags":"-1","flag":0,"nick":"船长","qage":13,"rm":0},{"uin":908512516,"role":2,"g":-1,"join_time":1603158257,"last_speak_time":1616213271,"lv":{"point":435,"level":6},"card":"","tags":"-1","flag":0,"nick":"风屿","qage":9,"rm":0},{"uin":2503637088,"role":2,"g":0,"join_time":1603173864,"last_speak_time":1616171002,"lv":{"point":431,"level":6},"card":"吾爱交流吧","tags":"-1","flag":0,"nick":"一生…love you","qage":8,"rm":0},{"uin":2640597818,"role":2,"g":-1,"join_time":1605535025,"last_speak_time":1616219882,"lv":{"point":430,"level":6},"card":"","tags":"-1","flag":0,"nick":"游戏人生","qage":1,"rm":0},{"uin":794567545,"role":2,"g":-1,"join_time":1605512272,"last_speak_time":1616084681,"lv":{"point":427,"level":6},"card":"","tags":"-1","flag":0,"nick":"醉酒成梦°","qage":7,"rm":0},{"uin":154460336,"role":2,"g":0,"join_time":1603087369,"last_speak_time":1616091361,"lv":{"point":379,"level":6},"card":"IDE-炫彩中文编","tags":"-1","flag":0,"nick":"炫彩软件(梦飞)","qage":18,"rm":0}],"count":1452,"svr_time":1616222734,"max_count":3000,"search_count":1452,"extmode":0}



以上JSON**,是群成员列表,需求是:

1,得出 mems 下面的数组数量,在易语言里面zyjson.取成员数("mems")可以知道,但是在火山不知道用什么方法;

2,对应的遍历出所有群成员的 uin  和 nick  ;

火山关于json的例子非常少,没有一个很详细的关于官方的那个JSON库的使用例程,拜托各位大佬指点下~~~
回复

使用道具 举报

444

主题

1万

帖子

4万

积分

超级版主

Rank: 8Rank: 8

积分
40549
沙发
发表于 2021-3-20 22:39:19 | 只看该作者
本帖最后由 创世魂 于 2022-8-10 11:37 编辑

http://doc.voldp.com/vol_Android/JSON/json_duixiang.htm   这个图文教程还不够详细吗???
http://doc.voldp.com/vol_Android/JSON/json_shuzu.htm    json数组教程。。还是这个解释的不清楚。。



看完这两个教程,绝对可以会解析出来json

安卓无障碍实战课:点击查看
交流群:641526939
回复

使用道具 举报

444

主题

1万

帖子

4万

积分

超级版主

Rank: 8Rank: 8

积分
40549
板凳
发表于 2021-3-20 22:46:48 | 只看该作者

火山视窗的json解析方法,很简单的。。

QQ截图20210320224633.jpg (26.43 KB, 下载次数: 76)

QQ截图20210320224633.jpg
安卓无障碍实战课:点击查看
交流群:641526939
回复

使用道具 举报

3

主题

18

帖子

383

积分

中级会员

Rank: 3Rank: 3

积分
383
地板
 楼主| 发表于 2021-3-20 23:01:30 | 只看该作者
还是版主热心,感谢:噜阿噜
回复

使用道具 举报

3

主题

18

帖子

383

积分

中级会员

Rank: 3Rank: 3

积分
383
5#
 楼主| 发表于 2021-3-21 00:07:23 | 只看该作者
创世魂 发表于 2021-3-20 22:46
火山视窗的json解析方法,很简单的。。
不太对,按照你这写法,计次循环  里面   JSON对象.取文本值(“//........” )  这代码是错误的......
回复

使用道具 举报

444

主题

1万

帖子

4万

积分

超级版主

Rank: 8Rank: 8

积分
40549
6#
发表于 2021-3-21 13:25:24 | 只看该作者
无夜 发表于 2021-3-21 00:07
不太对,按照你这写法,计次循环  里面   JSON对象.取文本值(“//........” )  这代码是错误的...... ...

到文本(取循环索引())   这点小问题,自己转换一下就行了。。
安卓无障碍实战课:点击查看
交流群:641526939
回复

使用道具 举报

3

主题

18

帖子

383

积分

中级会员

Rank: 3Rank: 3

积分
383
7#
 楼主| 发表于 2021-3-21 17:40:41 | 只看该作者
创世魂 发表于 2021-3-21 13:25
到文本(取循环索引())   这点小问题,自己转换一下就行了。。

还有一个小错误,//mems.["....."]......

你的是//mems[“.....”].......

按照这么写,运行了直接闪退了
回复

使用道具 举报

0

主题

19

帖子

5353

积分

核心用户

Rank: 9Rank: 9Rank: 9

积分
5353
8#
发表于 2021-5-14 21:21:08 | 只看该作者
用 query 也可以实现
参考 JSON对象类 的 取文本值2 方法
@ @<欲操作本对象>.getString(@<键名>)
你把他那个 getString 改成 query 就行了

这个用法是 query ("#/mems/0/uin") 或者 query ("/mems/0/uin")
然后就可以取出来了
回复

使用道具 举报

0

主题

19

帖子

5353

积分

核心用户

Rank: 9Rank: 9Rank: 9

积分
5353
9#
发表于 2021-5-14 21:23:14 | 只看该作者
如果不想加异常处理,直接用 optQuery 就可以
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|递归火山软件开发平台 ( 鄂ICP备18029190号 )

GMT+8, 2024-11-25 15:44 , Processed in 0.091610 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表