Skip to content

Instantly share code, notes, and snippets.

@conikeec
Forked from v6ak/gist:923233
Created December 11, 2011 07:37
Show Gist options
  • Save conikeec/1459133 to your computer and use it in GitHub Desktop.
Save conikeec/1459133 to your computer and use it in GitHub Desktop.
Some ideas for Lift JSON intergation in Play! framework
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