lua解析json
发布日期:2021-06-30 19:39:28
浏览次数:2
分类:技术文章
本文共 1366 字,大约阅读时间需要 4 分钟。
转载注明出处:
需要解析的json数据gui-config.json
{ "configs": [{ "server": "JP3.ISS.TF", "server_port": 443, "password": "58603228", "method": "aes-256-cfb", "remarks": "" }, { "server": "US1.ISS.TF", "server_port": 443, "password": "37382928", "method": "aes-256-cfb", "remarks": "" }, { "server": "HK2.ISS.TF", "server_port": 8989, "password": "59434206", "method": "aes-256-cfb", "remarks": "" }], "strategy": null, "index": 0, "global": false, "enabled": true, "shareOverLan": false, "isDefault": false, "localPort": 1080, "pacUrl": null, "useOnlinePac": false, "availabilityStatistics": false }
LUA解析代码:
function FileRead() local file = io.open("gui-config.json", "r"); local json = file:read("*a"); file:close(); return json; end function FileWrite() local file = io.open("gui-config.json", "w"); file:close(); end local cjson = require("cjson"); local file = FileRead(); local json = cjson.decode(file); for i, w in ipairs(json.configs) do print("server: " .. w.password) print("server_port: " .. w.server_port) print("password: " .. w.password) print("method: " .. w.method .. '\n') end
输出:
转载地址:https://linxinfa.blog.csdn.net/article/details/76557700 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关注你微信了!
[***.104.42.241]2024年05月01日 17时49分28秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Linux添加系统调用
2019-04-30
linux内存的寻址方式
2019-04-30
ubunut16.04的pip3出现问题,重新安装pip3
2019-04-30
how2heap-double free
2019-04-30
how2heap-fastbin_dup_consolidate
2019-04-30
orw_shellcode_模板
2019-04-30
[fmt+shellcode]string
2019-04-30
fmt在bss段(neepusec_easy_format)
2019-04-30
[double free] 9447 CTF : Search Engine
2019-04-30
python 函数式编程
2019-04-30
python编码
2019-04-30
scala maven plugin
2019-04-30
flink 1-个人理解
2019-04-30
redis cli
2019-04-30
redis api
2019-04-30
flink physical partition
2019-04-30
java 解析json
2019-04-30
java http请求
2019-04-30
tensorflow 数据格式
2019-04-30