Created
September 27, 2012 11:43
-
-
Save ussy/3793587 to your computer and use it in GitHub Desktop.
Jerkson is available on play2 development mode from http://takezoe.blogspot.com/2012/08/jerkson-in-play2-development-mode.html
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
import play.api.Play._ | |
import play.api.Play.current | |
import com.codahale.jerkson._ | |
object JSON { | |
def stringify(o: Any): String = if (isDev) { new Json{}.generate(o) } else { Json.generate(o) } | |
def parse[T](json: String)(implicit m: Manifest[T]): T = try { | |
if (isDev) { new Json{}.parse[T](json) } else { Json.parse[T](json)} | |
} catch { | |
case(e: ParsingException) => throw new JSONParsingException(e) | |
} | |
} | |
class JSONParsingException(val cause: Exception) extends Exception |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment