How can an extension method be written to remove all keys with a null
value from an Argonaut Json
object:
I tried this:
package object Extensions {
implicit class JsonExtensions(val json: Json) extends AnyVal {
def removeNulls: Json = {
json.withObject(j => JsonObject.from (j.toMap.filter(!_._2.isNull).toList))
}
}
}
but it only seems to be removing keys with null
values at the top level of the Json
object...