Created
February 2, 2013 17:11
-
-
Save dcsobral/4698349 to your computer and use it in GitHub Desktop.
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
// At the external API level, use TypeTag | |
def extract[T: TypeTag](jsv: JsValue): T = | |
extractImpl[T](jsv, typeOf[T]) | |
// But use Type for everything else | |
def extractImpl[T](jsv: JsValue, tpe: Type): T = { | |
// no need for m | |
val ex = jsv match { | |
case JsNumber(n) => n | |
case JsString(s) => s | |
case JsArray(l) => { | |
// deep serialization | |
val intpe = m.typeSymbol.asType.typeParams.head.asType.toTypeIn(tpe) | |
l.map(in(_, intpe)) | |
} | |
//.. | |
} | |
} | |
def in[T](js: JsValue, tpe: Type): T = { | |
// no need for m | |
//.. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment