lua code: local jsonObj = {}; for ele in eles do jsonObj[idx] = ele; end; redis.call('publish', channel, cjson.encode(jsonObj)); //reports invalid value; Turns out that cjson.encode(jsonObj) results like:{"key1":"value2", "key2":"value2"..}, which is not a string for Redis. Try to add '' to cjson.encode(jsonObj), didn't work.

Comment From: itamarhaber

Hello @loversInJapan

I can't reproduce this, e.g.:

127.0.0.1:6379> EVAL "local t = {} t['foo'] = 'bar' return cjson.encode(t)" 0
"{\"foo\":\"bar\"}"
127.0.0.1:6379> EVAL "local t = {} t['foo'] = 'bar' return type(cjson.encode(t))" 0
"string"
127.0.0.1:6379> EVAL "local t = {} t['foo'] = 'bar' return redis.call('PUBLISH', 'baz', cjson.encode(t))" 0
(integer) 0

Keep in mind that this issue tracker should be used for reporting bugs or proposing improvements to the Redis server. Questions should be directed to the community: