klarna / erlavro

Avro support for Erlang/Elixir (http://avro.apache.org/)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Options to decode keys as atoms

davydog187 opened this issue · comments

I was looking to decode keys to atoms as an option in cogini/avro_schema@2c07ca2 and cogini/avro_schema#25

However, as far as I can reason through the erlavro decoder hook code, I don't think it is possible to implement this as a decoder hook. In this case, it might make more sense to implement this feature directly into erlavro, and provide options similar to the Jason.decode/2 function.

I am happy to implement, but I would appreciate feedback if I'm wasting my time and this is easily implemented as a decoder hook. Thanks!

I'd say go ahead add a new decoder option.

For records and enums, ideally it should be atom() in schema,
i.e. ensure atom() at schema's 'compile' time.
in this case, we do not need to convert binary() to atom() over and over again.
But this is likely a big change and may break backward compatibility.