mpx / lua-cjson

Lua CJSON is a fast JSON encoding/parsing module for Lua
https://kyne.au/~mark/software/lua-cjson.php
MIT License
933 stars 478 forks source link

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

Open mythay opened 9 years ago

mythay commented 9 years ago

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

lipp commented 9 years ago

:+1:

mpx commented 8 years ago

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.

brimworks commented 8 years ago

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.