使用 lift-json 支持的 json4s,如果我执行以下操作:
val foobar = ("foo" -> JNothing) ~ ("bar" -> 42)
println(write(foobar))
输出为:
{, "bar":42}
这不是有效的 JSON。我想获得:
{"foo":null, "bar":42}
有没有办法将JNothing
序列化为null
?
最佳答案
我发现,如果将 JNothing
替换为 JNull
,我会得到我期望的结果。
关于scala - 如何将 JNothing 序列化为 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17521844/