In my application, I need to have some Option
s encode to null
when empty and others excluded when empty. Based on the signature of Encoder
this doesn't seem to be possible for a special type wrapping Option
. Is there a good way to handle this?
Edit: In other answers (like Encoding Scala None to JSON value using circe) this question has been touched upon but with no suitable solution. In all of the answers supplied it is an explicit workaround that must be dealt with. I'm looking for a more general fix going forward. This is ultimately something that seems to be a missing feature in Circe, and (according to @travis-brown) will be addressed in the near future.