Skip to content

Instantly share code, notes, and snippets.

@ussy
Created September 27, 2012 11:43
Show Gist options
  • Save ussy/3793587 to your computer and use it in GitHub Desktop.
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
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