需要修改的Json数据gui-config.Json
{ "configs": [{ "server": "JP3.ISS.TF","server_port": 443,"password": "58603228","method": "aes-256-cfb","remarks": "" },{ "server": "US1.ISS.TF","password": "37382928",{ "server": "HK2.ISS.TF","server_port": 8989,"password": "59434206","remarks": "" }],"strategy": null,"index": 0,"global": false,"enabled": true,"shareOverLan": false,"isDefault": false,"localPort": 1080,"pacUrl": null,"uSEOnlinePac": false,"availabilityStatistics": false}
function fileRead() local file = io.open("gui-config.Json","r"); local Json = file:read("*a"); file:close(); return Json;endfunction fileWrite() local file = io.open("gui-config.Json","w"); file:close();endlocal 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
输出:
总结以上是内存溢出为你收集整理的LUA解析json小demo全部内容,希望文章能够帮你解决LUA解析json小demo所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)