Last active
August 29, 2015 14:26
-
-
Save kryptt/ae2b192a7ebedcc62f54 to your computer and use it in GitHub Desktop.
cleanup dissallowed fields
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
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