Created
July 18, 2018 18:01
-
-
Save stanislav-chetvertkov/90807ab4f3e78f0cabccacb2b606c410 to your computer and use it in GitHub Desktop.
json omit nulls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
implicit class FooBar(val json: Json) extends AnyVal { | |
def omitNull: Json = json | |
.mapArray(_.map(_.omitNull)) | |
.mapObject(_ | |
.filter { case (_, v) => !v.isNull } | |
.mapValues(_.omitNull) | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment