json - Redis Lua Differetiating empty array and object -
i encountered bug in cjson lua when using script in redis 3.2 set particular value in json object.
currently, lua in redis not differentiate between empty json array or empty json object. causes serious problems when serialising json objects have arrays within them.
eval "local json_str = '{\"items\":[],\"properties\":{}}' return cjson.encode(cjson.decode(json_str))" 0
result:
"{\"items\":{},\"properties\":{}}"
i found solution https://github.com/mpx/lua-cjson/issues/11 wasn't able implement in redis script.
this unsuccessful attempt :
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 , mt.__is_cjson_array end local json_str = '{\"items\":[],\"properties\":{}}' return cjson.encode(cjson.decode(json_str))" 0
any or pointer appreciated.
Comments
Post a Comment