How to represent optional fields in spray-json?

前端 未结 6 985
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 06:36

I have an optional field on my requests:

case class SearchRequest(url: String, nextAt: Option[Date])

My protocol is:

object Sea         


        
6条回答
  •  梦如初夏
    2021-02-07 07:30

    Don't know if this will help you but you can give that field a default value in the case class definition, so if the field is not in the json, it will assign the default value to it.

提交回复
热议问题