lua-cjson icon indicating copy to clipboard operation
lua-cjson copied to clipboard

add new encode option method 'encode_empty_table' to control how to encode empty table.

Open mythay opened this issue 10 years ago • 3 comments

there are three possiable values for the parameter, dict/array/null If a table is empty, we can control the encoding result to an empty dictionary or empty array of null in json format

mythay avatar Sep 24 '15 01:09 mythay

:+1:

lipp avatar Sep 24 '15 06:09 lipp

I think this would be better handled by a metatable to specify whether an object or table is needed. That would allow more consistent use of types.

mpx avatar Aug 24 '16 12:08 mpx

Please see https://github.com/mpx/lua-cjson/issues/11

...I agree with @mpx that this needs to be done on a per-value basis rather than a per-encode operation since you may want to mix an empty JSON object with an empty JSON array.

brimworks avatar Aug 25 '16 04:08 brimworks