FasterXML / FasterXML/jackson-module-scala

Integer runtime value in a collection typed as Double

Open
#275 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
506
Forks
138
Avg merge
3h 6m
Merged PRs (30d)
48

Description

Easily reproducible :

``` scala
import com.fasterxml.jackson.annotation.JsonInclude
import com.fasterxml.jackson.core.util.{DefaultPrettyPrinter, MinimalPrettyPrinter}
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper

object ObjMapper extends ObjectMapper with ScalaObjectMapper {
setSerializationInclusion(JsonInclude.Include.NON_NULL)
registerModule(DefaultScalaModule)
val prettyWriter = writer(new DefaultPrettyPrinter)
val miniWriter = writer(new MinimalPrettyPrinter)
}

case class Foo(timestamp: String, result: Map[String, Double])

class PLAY extends BaseSuite {

"succeeds" in {
val json =
"""
|[ {
| "count" : 10800
| }
|]
""".stripMargin

val map = ObjMapper.readValue[List[Map[String,Double]]](json).head
assert(map("count").isInstanceOf[Double])
}

"fails" in {
val json =
"""
|{
| "timestamp" : "2015-01-01T00:00:00.000Z",
| "result" : {
| "count" : 10800
| }
|}
""".stripMargin

val map = ObjMapper.readValue[Foo](json).result
assert(map("count").isInstanceOf[Double])
}

}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.