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

Allow tuples in input terms with the [tuples_to_lists] option #148

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

brigadier
Copy link

@brigadier brigadier commented Mar 11, 2021

Allow encoding terms containing tuples with the [tuples_to_lists] option of the encode function. Tuples are encoded as lists. No exception is made for the [{}] and [{k, v}, ...] special cases, and in the current implementation DateTime objects are also encoded as lists.

The rationale for this pull is that in newer erlang projects structures represeting key -> value pairs generally move from proplists to maps, encode and decode functions are not invertible anyway, and transforming manually each and every tuple to list manually before encoding is a tedious job.

Without this option it is fully compatible with previous versions.

I can also add conversion of one-tuple and two-tuple to timestamps, but not sure if this should be default behaviour or a configurable with another paremeter(s) one.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
brigadier and others added 3 commits March 11, 2021 22:55
Co-authored-by: Paulo F. Oliveira <paulo.ferraz.oliveira@gmail.com>
Co-authored-by: Paulo F. Oliveira <paulo.ferraz.oliveira@gmail.com>
Co-authored-by: Paulo F. Oliveira <paulo.ferraz.oliveira@gmail.com>
@brigadier
Copy link
Author

brigadier commented Mar 11, 2021

I'd add that this pull is not ready for getting accepted yet until I add support for datetimes and some tests. It's here for discussing about whether should it be accepted or not.

@paulo-ferraz-oliveira
Copy link
Contributor

You can convert this to a draft if you think it better signals your intention.

README.md Outdated Show resolved Hide resolved
brigadier and others added 2 commits March 12, 2021 09:29
Co-authored-by: Paulo F. Oliveira <paulo.ferraz.oliveira@gmail.com>
Co-authored-by: Paulo F. Oliveira <paulo.ferraz.oliveira@gmail.com>
@brigadier brigadier marked this pull request as draft March 12, 2021 06:30
@brigadier brigadier marked this pull request as ready for review March 13, 2021 14:13
… C} and {{A, B, C}, {D, E, F}} to datetime. Converts to lists instead.
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.

None yet

2 participants