The extra argument should be a table which, when looked up with an empty table key, would yield a truthy value if that empty table should be encoded as a JSON empty array ([]) instead of an empty object ({}).
Needless to say, the lookup table's metatable is honored so you can in fact do pretty much any checks in its __index metamethod.
This is more flexible than #15 and doesn't require modifying the encoded data like #25.
The extra argument should be a table which, when looked up with an empty table key, would yield a truthy value if that empty table should be encoded as a JSON empty array (
[]
) instead of an empty object ({}
).Needless to say, the lookup table's metatable is honored so you can in fact do pretty much any checks in its
__index
metamethod.This is more flexible than #15 and doesn't require modifying the encoded data like #25.