convertJsonValue fails for JsNumbers
Closed this issue · 0 comments
etspaceman commented
it should "work" in {
val filters = Map("table" -> Json.toJson("table"), "client_id" -> Json.toJson(0))
val js = Json.toJson(filters).as[JsObject]
val asQueryParams = PlayJsonQueryParams(js).toJsonObject
println(asQueryParams)
assert(true)
}
}
Leads to:
Unsupported type for JsonObject: class scala.math.BigDecimal
java.lang.IllegalArgumentException: Unsupported type for JsonObject: class scala.math.BigDecimal
at com.couchbase.client.java.document.json.JsonObject.put(JsonObject.java:191)
at org.reactivecouchbase.rs.scaladsl.json.JsonConverter$.$anonfun$convertToJson$1(converter.scala:20)
...
This is because JsNumber returns a scala BigDecimal, which is not handled in the Couchbase java library.
Simply doing the following in convertJsonValue will fix the problem:
case JsNumber(n) => n.bigDecimal