Created
April 16, 2011 16:13
-
-
Save v6ak/923233 to your computer and use it in GitHub Desktop.
Some ideas for Lift JSON intergation in Play! framework
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 Foo0 extends Controller{ | |
def bar = Json(createAnObject) // Default serialization is used. | |
def bar2 = Json(createAnObject, createAnotherFormats) // default formats are overriden | |
} | |
object Foo1 extends Controller{ | |
// The first idea of specifying formats for a Controller is overriding a default method. | |
override protected def liftJsonFormats = createFormats // specify default formats | |
// I can copy&paste bar and bar2 methods there, but you probably know them. | |
} | |
object Foo2 extends Controller( | |
liftJsonFormats = createFormats() // Another idea of specifying formats is passing a constructor parameter. Which one is better? | |
){ | |
// I can copy&paste bar and bar2 methods there, but you probably know them. | |
} | |
object Foo3 extends Controller( | |
jsonAdapter = new LiftJsonAdapter(createFormats()) // Maybe we should not rely on a specific library. | |
){ | |
def bar = Json(createAnObject) | |
def bar2 = Json(createAnObject, new LiftJsonAdapter(createAnotherFormats)) // default formats are overriden | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment