You misunderstand something about Lua. Unless compiled otherwise, the "number" type is a double, and your output is printing out:
1) "Ask Lua what type 1.2 is ..." -- the literal string you told it to
2) "number" -- the type of the decoded 1.2
3) "float" -- the attribute name
4) (integer) 1 -- the attribute value, converted to a "proper" output format
Note that when Redis returns data from a Lua script (or sends it to the log), part of the process converts numbers to their integer equivalent. So in this case it's not that the cjson library is broken, it is that the way Redis converts numbers from Lua to the caller and to the log is not precise.
127.0.0.1:6379> eval "return cjson.decode(ARGV[1])['float'] * 5" 0 '{"float":1.2}'
(integer) 6
127.0.0.1:6379> eval "return cjson.decode(ARGV[1])['float'] * 3" 0 '{"float":1.2}'
(integer) 3
When I need to transfer information between Redis and Lua and clients anything beyond a string or integer, I always try to explicitly encode my data (to json or similar).
- Josiah