cjson encoding and decoding array results in an object #856

Closed
romansky opened this Issue Dec 31, 2012 · 3 comments

Comments

Projects
None yet
2 participants
@romansky

Hi,

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

redis 127.0.0.1:6379[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..

@romansky

This comment has been minimized.

Show comment Hide comment
@databus23

This comment has been minimized.

Show comment Hide comment
@databus23

databus23 Jan 24, 2013

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.

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.

@romansky

This comment has been minimized.

Show comment Hide comment
@romansky

romansky Jan 27, 2013

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.

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.

@romansky romansky closed this Jan 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment