I have found that, if I replace JNothing
for JNull
, I get the results that I expect.
How to serialize JNothing as null
Question
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
?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow