With lift-json backed json4s, if I do the following:

val foobar = ("foo" -> JNothing) ~ ("bar" -> 42) 
println(write(foobar))

The output is:

{, "bar":42}

which is not valid JSON. I would like to obtain:

{"foo":null, "bar":42}

Is there any way to serialize JNothing into null?

有帮助吗?

解决方案

I have found that, if I replace JNothing for JNull, I get the results that I expect.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top