param1 = arg[1] param2 = arg[2] print("json_file_name:"..param1..", remove key:"..param2) local cjson = require("cjson") local file = io.open(param1, "r") local content = file:read("*all") file:close() local data = cjson.decode(content) local function removeB(obj) if type(obj) == "table" then for k, v in pairs(obj) do if k == param2 then obj[k] = nil else removeB(v) end end end end removeB(data) local newContent = cjson.encode(data) file = io.open(param1, "w") file:write(newContent) file:close()