I need some help with BigDecimal deserialization.
protected implicit val jsonFormats: Formats = DefaultFormats.withBigDecimal
I done this example code:
case class Test(value: BigDecimal)
class BigDecimalTest extends MyAppStack with NativeJsonSupport {
protected implicit val jsonFormats: Formats = DefaultFormats.withBigDecimal
get("/") {
Test(BigDecimal("1.23"))
}
post("/") {
val o = parsedBody.extract[Test]
println(o)
o
}
}
When I call the get method I receive:
{"value":1.23}
But when I try to send the same json to the post method I receive:
No usable value for value Do not know how to convert JDouble(1.23) into class scala.math.BigDecimal
org.json4s.package$MappingException: No usable value for value Do not know how to convert JDouble(1.23) into class scala.math.BigDecimal
I tried to use JacksonJsonSupport instead of NativeJsonSupport, but I runt into the same problem.
I'm using scalatra 2.2.2 and json4s 3.2.7.
Thanks for the help,
Filipe.