1

Hi I have my case class defined as so

case class bread (
  @ObjectId @JsonProperty("_id") id: Option[String] = None,
  @JsonProperty("yeast_level") yeastLevel: Int,
  @JsonProperty("name") name: String
)

My Json looks like this

{
  "id": "1923109230",
  "yeastLevel": 4,
  "name": "apple"
}

and I first parse the json into a Bread object

When I try to insert the bread object into mongodb thru the MongoJack it keeps giving me an exception.

org.mongojack.MongoJsonMappingException: Error mapping BSON to POJOs

When I put an option around the other two fields like that it does not result in the exception. Can you not make the objectId optional?

Help appreciated and thanks

Teddy Dong
  • 362
  • 1
  • 6
  • 20
  • Or the [Play JSON support for ReactiveMongo](http://reactivemongo.org/releases/0.12/documentation/tutorial/play.html) could be used – cchantep Jul 25 '17 at 00:15
  • hi @cchantep do you mean use that instead of mongojack? I will need to use mongojack at present time... – Teddy Dong Jul 25 '17 at 00:16

0 Answers0