Created
April 12, 2018 03:24
-
-
Save TRBaldim/a216690f7aedd8f87053f86f5f068c45 to your computer and use it in GitHub Desktop.
Get all keys with play api.
This file contains hidden or 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
| object KeysTracker { | |
| def allKeys(json: JsValue, parent: String): Seq[String] = json match { | |
| case JsObject(fields) => (fields.map(parent + "." + _._1) ++ fields.map(x => allKeys(x._2, parent + "." + x._1)).flatMap(_.toSeq)).toSeq | |
| case JsArray(as) => as.flatMap(x => allKeys(x, parent)) | |
| case _ => Seq.empty[String] | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment