I am trying to port a Rails / Mongodb application to Play 2.3 using play-reactivemongo and reactivemongo-extensions. When modeling my data, I ran into the problem of serializing and deserializing Map [Int, Boolean].
When I try to define my formats using a macro, so
implicit val myCaseClass = Json.format[MyCaseClass]
where MyCaseClass has several string fields, a BSONObjectID field and a Map [Int, Boolean] field, the compiler complains about:
No Json serializer found for type Map[Int,Boolean]. Try to implement an implicit Writes or Format for this type. No Json deserializer found for type Map[Int,Boolean]. Try to implement an implicit Reads or Format for this type.
Looking at the source code for Play in Reads.scala, I see that Reads is defined for Map [String, _], but not for Map [Int, _].
Is there a reason why Play has a Read / Writes default value for string cards, but not other simple types?
I donβt quite understand the map [String, _] defined by the game, because I'm pretty new to scala. How do I translate this to the [Int, _] card? If this is not possible for some technical reason, how can I define Reads / Writes for Map [Int, Boolean]?