In some cases, default values make more sense than options in case classes:
case class Car(numberOfWheels:Int = 4, color:String)
case class Car(numbeOfWheels:Option[Int], color:String)
In the first case, I expect that you can easily convert the following json to an instance:
{"color":"red"}
But with standard jsonFormat2(Car), spray-json complains about the lack of value for numberOfWheels.
How can I get around this most cleanly?
source
share