I asked this question in scala-salat Google group, but no response there for a few days, hence trying here.
I have a case class which has a collection wrapped in an Option
.
case class SomeClass(
var name:Option[String]=None,
var addresses:Option[Set[Address]]=None
)
case class Address(
var street:Option[String]=None,
var zip:Option[String]=None
)
The document gets stored in Mongo just fine. However, when I try to get this using findOne
(with or without SalatDAO
) the addresses field has JSON text representing addresses instead of the Address case class.
As a result, Lift-JSON skips any fields in my case class with Option[Collection[A]]
in it. When I remove the Option
and just go with addresses=Set[Address]()
, it works. However now I end up with empty sets in my JSON where there is no data, and I have no way to find out on an update if the consumer removed the entries, or I am getting an empty Set
because the consumer did not send this field in the original request.
Using Option
would have set the field to None
, which would mean that I would not have to worry about it being empty or modified.
Any help will be greatly appreciated.
Sorry, Salat does not currently support an Option that contains a collection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With