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
{ | |
"Basic Types" : { | |
"uid" : { | |
"type" : "UID", | |
"config" : { | |
"placeholder" : "Unique Document Identifier" | |
} | |
}, | |
"text" : { | |
"type" : "Text", |
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
def flattenObject(obj: JsObject, prefix: Option[String] = None) :Seq[(String, JsValue)] = { | |
obj.fields.toList match { | |
case ("$date",_) :: Nil if prefix.isDefined => Seq(prefix.get -> obj) | |
case ("$date",_) :: Nil => throw new Exception("Can't save $date at the first level.") | |
case fs => fs.flatMap { t => | |
val name = prefix.map(_ + ".").getOrElse("") + t._1 | |
t._2 match { | |
case obj: JsObject => flattenObject(obj, Some(name)) | |
case value => Seq(name -> value) | |
} |