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

Ordered table #25

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Ordered table #25

wants to merge 5 commits into from

Conversation

grafi-tt
Copy link
Owner

@grafi-tt grafi-tt commented Jan 4, 2019

preserveorder option added to decoder, using a custom ordered table implementation similar to http://lua-users.org/wiki/OrderedTable (Last edited June 23, 2015 8:15 am GMT). This implementation relies on __pairs metamethod. Encoder is modified to patch old pairs function.

While I think using __pairs metamethod is the cleanest way, I'm not yet decided. As suggested on #4, saving the order with integer indices is also possible. obj[0] could be -1 for distinction to arrays. It is somewhat consistent with arraylen option, which uses array[0] instead of __len metamethod.

@tst2005 tst2005 mentioned this pull request Jan 9, 2019
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