Skip to content

Instantly share code, notes, and snippets.

@TRBaldim
Created April 12, 2018 03:24
Show Gist options
  • Select an option

  • Save TRBaldim/a216690f7aedd8f87053f86f5f068c45 to your computer and use it in GitHub Desktop.

Select an option

Save TRBaldim/a216690f7aedd8f87053f86f5f068c45 to your computer and use it in GitHub Desktop.
Get all keys with play api.
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