1

My understanding is that json-lift supports Option fields out of the box.

Here is a sample object definition:

class TopicModel (
    var id: Option[Long],
    var name: String,
    val slug: String,
    var imageUrl: Option[String] )
{}

I then use net.liftweb.json.Serialization.read[Topic](jsonString) to read the object

If all fields in the incoming JSON are present, deserialization works fine. However, if I omit an Option field:

{"id": "35", "name": "My topic", "slug": "my-slug" /** imageUrl missing */}

object comes back with all fields set to null.

Another interesting fact: this is only a problem when the code is under app directory of the play app. If we put it elsewhere and include as a jar it works just fine.

There is an opinion that this is a problem with Scala 2.8 (we're on Play 1.2.3 / Akka 1.0 and are limited from using latest Scala).

Any help would be appreciated...

4

0 に答える 0