opened
Apelsinka223
username_0
Hi, thanks for package! I suggest to optionally support tuples.

In this request I added option `tuples: :list | :raise (default)` to `Jason.encode/2`, and on `:list` value - tuples would be encoded as lists with meta element "__tuple__" as the list head.   
Also I added `tuples: :tuple | :none (default)` option to `Jason.decode/2`, with `:tuple` value it would decode lists with "__tuple__" element in the head as tuples.

As default, `Jason.encode/2` and `Jason.decode/2` would work same as now.
Tuples support
issue
created
Apelsinka223
username_0
Dialyzer fails with `lib/encode.ex:238: Function tuple_raise/4 has no local return`, and I really have no idea how to fix it, already tried many ways.
comment
created
michalmuskala
username_1
Hi @username_0,

I appreciate this work. The implementation of the feature and the tests are very thorough, I couldn't have written it better myself. Unfortunately, I'm not sure this feature belongs in the library. Let me explain:

The goal of Jason is to be a semantic encoder/decoder of JSON and not a general encoder/decoder of arbitrary Elixir terms. JSON itself doesn't have tuples - to deal with this deficiency, the PR introduces a "magic" `"__tuple__"` tag, but such conversion introduces application-specific logic and is not general. It couldn't be decoded into proper data by an arbitrary decoder.

Perhaps a format that builds on top of JSON, such as [Transit](https://github.com/cognitect/transit-format), would be a better fit for such a feature? It has an explicit extension points for custom formates, but includes built-in definitions for arrays (which would correspond to tuples), lists or maps with composite terms.
comment