Skip to content

Instantly share code, notes, and snippets.

@chrislewis
Created August 16, 2011 01:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrislewis/1148265 to your computer and use it in GitHub Desktop.
Save chrislewis/1148265 to your computer and use it in GitHub Desktop.
lazy json conversion via lift-json with explicit pimp
object LazyJson {
import net.liftweb.json._
import net.liftweb.json.Extraction._
/* Hintless format. Used by decompose, which will end up doing reflective footwork. */
implicit val formats = Serialization.formats(NoTypeHints)
/* Pimp anything with toJson using a reflective conversion. */
implicit def any2JValue(any: Any): AnyPimp = new AnyPimp(any)
class AnyPimp(a: Any) {
def toJson = decompose(a)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment