local cjson = require("cjson.safe")
local cfg_file_path = './cfg.json'
local cfg_fd = io.open(cfg_file_path, 'r')
local cfg_contents = cfg_fd:read("*all")
local cfg_obj = cjson.decode(cfg_contents)
for key, value in pairs(cfg_obj) do
print(value)
end
environment: lua5.3 and lua-cjson 2.1.0.10-1
json file: cfg.json
lua code:
the printout result: 192.168.1.100 10000.0