res = ngx.location.capture('/update',{method = ngx.HTTP_POST,body = "name=" .. name .. "&content=" .. content})
local cjson = require("cjson") local data = cjson.decode(res.body)
若是返回的不是json格式,則這段lua腳本會報錯json
Expected value but found invalid token at character 1 stack traceback: coroutine 0: [C]: in function 'decode'
local cjson = require("cjson.safe") local data = cjson.decode(res.body) if data==nil then --.... end