Avoid serialize to null using Circe json serializer

不羁岁月 提交于 2019-12-24 00:10:03

问题


How to avoid serializing None to null using Circe json serializer? I am not able to force this library to skip serializing fields which are None. Is it possible to achieve?


回答1:


I found the solution. We can provide implicit variable of instance Printer with our configuration. https://github.com/circe/circe/blob/master/modules/core/shared/src/main/scala/io/circe/Printer.scala We can set dropNullKeys to null and everything is working like a charm.



来源:https://stackoverflow.com/questions/41721970/avoid-serialize-to-null-using-circe-json-serializer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!