Created
August 16, 2011 01:28
-
-
Save chrislewis/1148265 to your computer and use it in GitHub Desktop.
lazy json conversion via lift-json with explicit pimp
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
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