scala - What is a good way to handle default values with spray-json -


in cases default values make more sense optionals in case classes:

case class car(numberofwheels:int = 4, color:string)  case class car(numbeofwheels:option[int], color:string) //silly 

in first case i'd expect able convert following json instance:

{"color":"red"} 

but standard jsonformat2(car), spray-json complains missing value numberofwheels.

how work around cleanly?

i stumbled upon same problem. i've create patch solves me. makes fields default value optional.

https://github.com/spray/spray-json/pull/56

update: pr updated , still open https://github.com/spray/spray-json/pull/93


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -