[Freeswitch-users] freeswitch won't open file
Joli Martinez
mrjoli021 at gmail.com
Fri Dec 4 19:48:01 UTC 2020
Hello,
I have the following function that works normally on lua, but when I copied
and pasted it into my freeswitch lua script, the file wont open. I am
trying to put the passwords I use in a json format outside the script, so
that I can share the script. I have installed the correct libraries for
lunajson to work.
Any suggestions?
--Reads json file and parses it
function returnJson(option)
freeswitch.consoleLog("INFO", "Inside function\n")
local file = io.open("password.json", "r")
if not file then
return nil
end
local jsonString = file:read("*a")
freeswitch.consoleLog("INFO", "File is open\n")
file:close()
jsonResult = lunajson.decode( jsonString )
freeswitch.consoleLog("INFO", "Parsing json\n")
return ( jsonResult[option] )
end
--SID = returnJson("SID")
--Token = returnJson("TOKEN")
------------------------------------------------------------------------------------------------------------
2020-12-04 14:38:13.637108 [ERR] mod_lua.cpp:203
/usr/share/freeswitch/scripts/test.lua:67: attempt to concatenate global
'SID' (a nil value)
stack traceback:
/usr/share/freeswitch/scripts/test.lua:67: in main chunk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20201204/510f5b07/attachment.html>
More information about the FreeSWITCH-users
mailing list