jsx icon indicating copy to clipboard operation
jsx copied to clipboard

Allow tuples in input terms with the [tuples_to_lists] option

Open brigadier opened this issue 3 years ago • 2 comments

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.

brigadier avatar Mar 11 '21 18:03 brigadier

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.

brigadier avatar Mar 11 '21 20:03 brigadier

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

paulo-ferraz-oliveira avatar Mar 12 '21 01:03 paulo-ferraz-oliveira