You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HI, I've created a scala worksheet to test object updates with Jackson (v 2.5.1). We I try to update the object (d12 below) I get an exception. If I test it in a standalone test app it works.
importcom.fasterxml.jackson.annotation.JsonPropertyimportcom.fasterxml.jackson.databind.ObjectMapperimportcom.fasterxml.jackson.module.scala.DefaultScalaModuleimportcom.fasterxml.jackson.databind.SerializationFeatureimportcom.fasterxml.jackson.annotation.PropertyAccessorimportcom.fasterxml.jackson.annotation.JsonAutoDetect.Visibilityimportcom.fasterxml.jackson.databind.ObjectReaderclassDataA {
@JsonPropertyvarvint:Int=3
}
objectjackson4 {
println("Welcome to the Scala worksheet") //> Welcome to the Scala worksheetvalmapper=newObjectMapper() //> mapper : com.fasterxml.jackson.databind.ObjectMapper = com.fasterxml.jackso//| n.databind.ObjectMapper@679e96f7
mapper.registerModule(DefaultScalaModule) //> res0: com.fasterxml.jackson.databind.ObjectMapper = com.fasterxml.jackson.da//| tabind.ObjectMapper@679e96f7
mapper.enable(SerializationFeature.INDENT_OUTPUT)
//> res1: com.fasterxml.jackson.databind.ObjectMapper = com.fasterxml.jackson.da//| tabind.ObjectMapper@679e96f7
mapper.setVisibility(PropertyAccessor.ALL, Visibility.NONE)
//> res2: com.fasterxml.jackson.databind.ObjectMapper = com.fasterxml.jackson.da//| tabind.ObjectMapper@679e96f7vald10=newDataA//> d10 : DataA = DataA@fb9165a
d10.vint =5vald10Json= mapper.writeValueAsString(d10) //> d10Json : String = {//| "vint" : 5//| }vald11= mapper.readValue(d10Json, classOf[DataA])
//> d11 : DataA = DataA@3c22de9evald11Json= mapper.writeValueAsString(d11) //> d11Json : String = {//| "vint" : 5//| }vald12=newDataA//> d12 : DataA = DataA@154575ea
mapper.readerForUpdating[ObjectReader](d12).readValue(d10Json)
//> java.lang.ClassCastException: DataA cannot be cast to scala.runtime.Nothing$//| //| at jackson4$$anonfun$main$1.apply$mcV$sp(jackson4.scala:29)//| at org.scalaide.worksheet.runtime.library.WorksheetSupport$$anonfun$$exe//| cute$1.apply$mcV$sp(WorksheetSupport.scala:76)//| at org.scalaide.worksheet.runtime.library.WorksheetSupport$.redirected(W//| orksheetSupport.scala:65)//| at org.scalaide.worksheet.runtime.library.WorksheetSupport$.$execute(Wor//| ksheetSupport.scala:75)//| at jackson4$.main(jackson4.scala:13)//| at jackson4.main(jackson4.scala)
}
I've found out that it works if I change the last line to:
HI, I've created a scala worksheet to test object updates with Jackson (v 2.5.1). We I try to update the object (
d12
below) I get an exception. If I test it in a standalone test app it works.I've found out that it works if I change the last line to:
It makes it work in the worksheet but it is not needed in the standalone app.
The text was updated successfully, but these errors were encountered: