Skip to content
This repository

cjson encoding and decoding array results in an object #856

romansky opened this Issue December 31, 2012 · 3 comments

2 participants

Roman Landenband Fabian Ruff
Roman Landenband


Not sure if this is the right place to log this issue (another specific cjson issues list?) anyway, this happens:

redis[13]> eval "return cjson.encode(cjson.decode('[]'))" 0

Which basically creates some bugs when decoding and encoding JSON objects using LUA when there's an empty array as a value somewhere..

Fabian Ruff

I think it's not a bug but a limitation of the lua language. The lua language uses tables to implement both array- and hash-type data structures. When decoding an empty hash or array from json they are both mapped to an empty lua table. There is no way of distinguishing them in lua.

Roman Landenband

thanks @databus23, I must have misread some code I linked, I re-read it just now and it seems that there was no work-around by some interesting technique as I have hoped..

Thanks for the reply.

Roman Landenband romansky closed this January 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.