Closed ghost closed 6 years ago
Correct me if I'm wrong but it seems to me you should use @derive
or Protocol.derive/3
on you struct for this (https://github.com/michalmuskala/jason/blob/master/README.md#differences-to-poison).
Yes, it's possible to encode the __struct__
field by manually implementing the encoder. It's even possible to use @derive Jason.Encoder, only: [:__struct__, ...]
to explicitly request the field to be encoded. The default when deriving the protocol without any options will remain to omit the field.
When encoding or decoding a struct it would be useful to add the ability to preserve the struct field so that it is not lost. Right now I have to decode then go back through and put the struct field back in and fix the data because it is lost.