Skip to content

Instantly share code, notes, and snippets.

@kevinmeredith
Created September 19, 2013 00:37
Show Gist options
  • Select an option

  • Save kevinmeredith/6617735 to your computer and use it in GitHub Desktop.

Select an option

Save kevinmeredith/6617735 to your computer and use it in GitHub Desktop.
java.lang.IllegalArgumentException: can't serialize class scala.math.BigDecimal
package test
import com.mongodb.casbah.Imports._
import org.scalatest._
import org.scalatest.matchers.ShouldMatchers
import play.api.libs.json._
import play.api.{Play, Logger}
class TestLoadingJsNumber extends FlatSpec with ShouldMatchers {
"Trying to Insert a JsNumber" should "throw a BSON exception when trying BigDecimal serialization" in {
val collection = MongoConnection()("test")("test")
val obj: JsValue = Json.obj("age" -> JsNumber(100))
println("Json.stringify(obj): " + Json.stringify(obj))
val q = MongoDBObject("name" -> obj)
collection.insert(q)
}
}
@kevinmeredith

Copy link
Copy Markdown
Author

Note that replacing val obj... with the below line also throws a BSON serialization exception.

val obj: JsValue = Json.obj("age" -> 100)

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