Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for an extra json_encode argument for empty table encoding resolution #48

Closed
wants to merge 1 commit into from
Closed

Adding support for an extra json_encode argument for empty table encoding resolution #48

wants to merge 1 commit into from

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