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