title: Redis Lua Differetiating empty array and object
body: <p>I encountered this bug in cjson lua when I was using a script in redis 3.2 to set a particular value in a json object.</p>
  
  <p>Currently, the lua in redis does not differentiate between an empty json array or an empty json object. Which causes serious problems when serialising json objects that have arrays within them.</p>
  
  <pre><code>eval "local json_str = '{\"items\":[],\"properties\":{}}' return cjson.encode(cjson.decode(json_str))" 0
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>"{\"items\":{},\"properties\":{}}"
  </code></pre>
  
  <p>I found this solution <a href="https://github.com/mpx/lua-cjson/issues/11" rel="noreferrer">https://github.com/mpx/lua-cjson/issues/11</a> but I wasn't able to implement in a redis script.</p>
  
  <p>This is an unsuccessful attempt : </p>
  
  <pre><code>eval 
  
  "function cjson.mark_as_array(t) 
  local mt = getmetatable(t) or {} 
  mt.__is_cjson_array = true 
  return setmetatable(t, mt) 
  end 
  function cjson.is_marked_as_array(t) 
  local mt = getmetatable(t) 
  return mt and mt.__is_cjson_array end 
  local json_str = '{\"items\":[],\"properties\":{}}' 
  return cjson.encode(cjson.decode(json_str))" 
  
  0
  </code></pre>
  
  <p>Any help or pointer appreciated.</p>