Skip to content

Conversation

szakharchenko
Copy link

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.

…ding resolution.

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 ({}).
@szakharchenko
Copy link
Author

Actually, I've found that an even more generic solution is even more useful in presence of table.pack(), etc. Disregard this.

@szakharchenko szakharchenko deleted the empty-array-encoding-lookup-table branch January 22, 2018 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant