|
发表于 2024-6-3 21:54:26
|
显示全部楼层
浙江省温州市
递归一下就好,没做太多判断,自行处理
json使用的是zyjson
窗口程序集名 | 保 留 | 保 留 | 备 注 | 程序集1 | | | | 变量名 | 类 型 | 数组 | 备 注 | m_files | 数据类型_file | 0 | 子程序1 ()返回 (0 ) 变量名 | 类 型 | 静态 | 数组 | 备 注 | json | zyJsonValue | | | count | 整数型 | | | i | 整数型 | | | path | 文本型 | | | obj | zyJsonValue | | | baseDir | 文本型 | | |
如果真 (json. 解析 ( #常量_json ) = 假) 调试输出 (“解析失败!”) 返回 ()count = json.取成员数 (“data”) 如果真 (count = 0 ) 调试输出 (“无数据”) 返回 () 计次循环首 (count, i ) obj = json. 取成员 (“data”, i - 1 ) 子程序_递归处理数据 (obj, “”) 计次循环尾 ()调试输出 (取数组成员数 (m_files )) baseDir = “c:\test20240603”目录_创建 (baseDir ) 计次循环首 (取数组成员数 (m_files ), i ) 调试输出 (i, m_files [i ].destDir, m_files [i ].name ) 如果真 (m_files [i ].destDir ≠ “” 且 目录_是否存在 (baseDir + m_files [i ].destDir ) = 假) 目录_创建 (baseDir + m_files [i ].destDir )  写到文件 (baseDir + m_files [i ].destDir + “\” + m_files [i ].name + “_下载地址.txt”, 到字节集 (m_files [i ].url )) 计次循环尾 ()|
子程序_递归处理数据 | | | |
jsonObj | zyJsonValue | | | | parent_path | 文本型 | | | |
变量名 | 类 型 | 静态 | 数组 | 备 注 | flag_sub | 逻辑型 | | | name | 文本型 | | | file | 数据类型_file | | | count | 整数型 | | | obj | zyJsonValue | | | i | 整数型 | | |
flag_sub = jsonObj. 是否存在 (“sub”)name = jsonObj. 取文本 (“name”) 如果真 (flag_sub = 假)  file.name = name  file.destDir = parent_path  file.url = jsonObj. 取文本 (“url”) 加入成员 (m_files, file ) 返回 () count = jsonObj. 取成员数 (“sub”) 计次循环首 (count, i ) obj = jsonObj. 取成员 (“sub”, i - 1 ) 子程序_递归处理数据 (obj, parent_path + “\” + name ) 计次循环尾 () |
|