json FieldSerializer on class with Option members fails on read
json serialization with FieldSerializer fails to read a class with option members. Here are two examples to reproduce the error:
----
Throws Exception: net.liftweb.json.MappingException: Parsed JSON values do not match with class constructor
----
Throws exception: net.liftweb.json.MappingException: unknown error
----
Discussion Page:
http://groups.google.com/group/liftweb/browse_thread/thread/970d83d942e40270
----
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))
Throws Exception: 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))
Throws exception: net.liftweb.json.MappingException: unknown error
----
Discussion Page:
http://groups.google.com/group/liftweb/browse_thread/thread/970d83d942e40270
Leave a comment
on 2011-10-20 14:55 *
By joni.freeman
Assigned to set to joni.freeman
Status changed from New to Fixed
(In revision:2dbccbb182dfbc555248df3d51a7c1b6517bda58) Add a test for already fixed bug (commit 9de55fce3f0a9cc60c96cc3a6495317ddd100fc0), fixes #1133
Branch: master
Branch: master