Considerations for Using nginx capture

  nginx

post

res = ngx.location.capture('/update',{method = ngx.HTTP_POST,body = "name=" .. name .. "&content=" .. content})

Parsing json

local cjson = require("cjson")
local data = cjson.decode(res.body)

If the return is not in json format, this lua script will report an error

Expected value but found invalid token at character 1
stack traceback:
coroutine 0:
    [C]: in function 'decode'

Security parsing json

local cjson = require("cjson.safe")
local data = cjson.decode(res.body)
if data==nil then
 --....
end

doc