[lift] Problem with json FieldSerializer on class with Option members

36 views
Skip to first unread message

Jesh

unread,
Oct 18, 2011, 2:34:58 PM10/18/11
to Lift
Hi all,

I'm having some trouble getting the field serialization working. Here
are two barebones example that shows the problem:

----
>> import net.liftweb.json._
import net.liftweb.json.Serialization._
class TestClass{
val field : Option[String] = Some("i am a string")
}
implicit val formats = DefaultFormats + FieldSerializer[TestClass]()
read[TestClass](write(new TestClass))

>> net.liftweb.json.MappingException: Parsed JSON values do not match with class constructor

----
>> import net.liftweb.json._
import net.liftweb.json.Serialization._
class TestClass{
var field : Option[Int] = None
}
val t = new TestClass
t.field = Some(5)
implicit val formats = DefaultFormats + FieldSerializer[TestClass]()
read[TestClass](write(t))

>> net.liftweb.json.MappingException: unknown error
----

version info: scala 2.9.1, lift 2.4-M4

Am I doing something wrong here? The field serializer seems to work
just fine when there are no option members.


Thanks for your help,
Jeshua Bratman

Joni Freeman

unread,
Oct 18, 2011, 3:33:19 PM10/18/11
to lif...@googlegroups.com
Hi,

Please file a ticket, looks like a bug.

Cheers Joni
Reply all
Reply to author
Forward
0 new messages