klarna / erlavro

Avro support for Erlang/Elixir (http://avro.apache.org/)
Apache License 2.0
131 stars 39 forks source link

Encode atoms as strings #98

Closed davydog187 closed 3 years ago

davydog187 commented 4 years ago

I've already submitted #97 for this, but I thought I'd open an issue in case there was some dialogue to be had. As mentioned in the issue, I'm not sure if this is controversial in Erlang, but in Elixir it is very common to encode atom values as strings. For example, https://hexdocs.pm/jason/Jason.html#encode/2 happily encodes atom values as strings.

This test shows this functionality: https://github.com/michalmuskala/jason/blob/v1.1.2/test/encode_test.exs#L51

We keep running into issues where we have datastructures that should be avro encoded, but we need to go through the map and change all atoms to strings before encoding. This seems cumbersome, and it would be much simpler if the encoder did it for you.