Skip to content

Comments

added encoding function for tuple datatype#211

Open
muralidharan3194 wants to merge 2 commits intodevinus:masterfrom
muralidharan3194:develop
Open

added encoding function for tuple datatype#211
muralidharan3194 wants to merge 2 commits intodevinus:masterfrom
muralidharan3194:develop

Conversation

@muralidharan3194
Copy link

Encoding tuple using Poison:

  • Converted the tuple to List using Tuple.to_list({1, 2.5,:atom , ‘string’}) operation then encoded the list using lists:foldr erlang function for iteration, which iterates in reverse order and each iterated value is encoded using respective encoding datatype function.

Input given:
image

output:
Screenshot from 2023-02-13 12-21-48

@muralidharan3194 muralidharan3194 marked this pull request as ready for review March 2, 2023 08:53
@azizk
Copy link

azizk commented Aug 12, 2024

I'm curious how this is meaningful, because in JSON there is no tuple data type. Could you describe a concrete use case for this?

In any case, it's always possible to implement the Poison.Encoder protocol in your own projects. It doesn't seem warranted to include this in Poison itself, although a discussion could be had if tuples were to be encoded as lists by default.

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.

2 participants