title: LUA load JSON configuration from file
body: <p>I'm trying to move old LUA method which was loading some JSON content from file into global variable into "class". But I get following errors all the time:</p>
  
  <pre><code>attempt to call field 'decode' (a nil value)
  attempt to index global 'cjson' (a nil value)
  </code></pre>
  
  <p>I don't know lua well but i tried almost all combinations without result so can you explain why this errors occurs?</p>
  
  <p>Current implementation of module looks like:</p>
  
  <pre><code>Config = {}
  Config.__index = Config
  
  function Config.create(config_filename)
     local cjson = require("cjson") 
     local config = {}               
     setmetatable(config,Config)  
  
     local f = io.open(config_filename, "r")
     local content = f:read("*a")
     f:close()
     config = cjson.decode(content)
  
     return config
  end
  
  return Config
  </code></pre>
  
  <p>As final result I want to execute something like this from other file:</p>
  
  <pre><code>local config_class = require("config")
  local config = config_class.create("/path/to/file.json")
  
  ngx.say(config:some_configuration_data())
  </code></pre>