json FieldSerializer on class with Option members fails on read #1133

Closed
jeshua opened this Issue Oct 20, 2011 · 2 comments

Comments

Projects
None yet
3 participants

jeshua commented Oct 20, 2011

json serialization with FieldSerializer fails to read a class with option members. Here are two examples to reproduce the error:



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

Member

jonifreeman commented Oct 21, 2011

(In [[r:2dbccbb182dfbc555248df3d51a7c1b6517bda58]]) Add a test for already fixed bug (commit 9de55fc), fixes #1133

Branch: master

@ghost ghost assigned jonifreeman Mar 1, 2012

etorreborre pushed a commit to etorreborre/framework that referenced this issue Dec 3, 2014

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment