避免使用 Circe json 序列化器序列化为 null

Avoid serialize to null using Circe json serializer

如何避免使用 Circe json 序列化程序将 None 序列化为 null?我无法强制此库跳过 None 的序列化字段。有没有可能实现?

我找到了解决方案。我们可以在我们的配置中提供实例 Printer 的隐式变量。 https://github.com/circe/circe/blob/master/modules/core/shared/src/main/scala/io/circe/Printer.scala 我们可以将 dropNullKeys 设置为 null,并且一切正常。