Created
February 25, 2014 12:34
-
-
Save josephpconley/9207995 to your computer and use it in GitHub Desktop.
Convert JSON object into an empty JSON object
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 JS { | |
def default(js: JsValue): JsValue = js match { | |
case JsObject(fields) => JsObject(fields.map(f => f._1 -> default(f._2))) | |
case JsString(s) => JsString("") | |
case JsArray(a) => JsArray() | |
case JsNumber(n) => JsNumber(0.0) | |
case JsBoolean(b) => JsBoolean(false) | |
case _ => JsString("") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment