Reputation: 392
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
Upvotes: 1
Views: 283