I have a simple script to parse json output from crt.sh. When I run the script from resty CLI I get the following error. Can someone help explain what's wrong with the script?
ERROR: test.lua:16: Expected the end but found T_OBJ_BEGIN at character 294
stack traceback:
test.lua:16: in function 'file_gen'
init_worker_by_lua:46: in function <init_worker_by_lua:44>
[C]: in function 'xpcall'
init_worker_by_lua:53: in function <init_worker_by_lua:51>
The code for test.lua is below:
=================================================
local http = require "resty.http"
local cjson = require "cjson"
local httpc = http.new()
local uri = "https://crt.sh/?q=%.".. arg[1] .. "&output=json"
local res, err = httpc:request_uri(uri, {
method = "GET",
ssl_verify = false
})
if not res then
ngx.say("failed to request: ", err)
return
end
value = cjson.decode(res.body)
================================================