Skip to content

Instantly share code, notes, and snippets.

@kryptt
Last active August 29, 2015 14:26
Show Gist options
  • Save kryptt/ae2b192a7ebedcc62f54 to your computer and use it in GitHub Desktop.
Save kryptt/ae2b192a7ebedcc62f54 to your computer and use it in GitHub Desktop.
cleanup dissallowed fields
import argonaut._, Argonaut._
Object example {
def cleanup(details: Json): Json = details
.withArray(_.map(cleanup))
.withObject(jo => JsonObject.from(jo.toList.map(cleanup)))
def cleanup(field: (JsonField, Json)): (JsonField, Json) = (field._1.toLowerCase, field._1, field._2) match {
case (pwd, k, _) if List("password", "passwd", "pass", "pwd").contains(pwd) => (k, jString("******"))
case (_, k, v) => (k, cleanup(v))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment