I have objects of type
Map[java.util.Locale, String]
How can I make Json Writes / Reads for this? I have looked at a couple other questions, but couldn't come up with a solution myself. I got (but not tested yet) something for Locale
implicit val localeReads: Reads[Locale] = new Reads[Locale] {
def reads(json: JsValue): JsResult[Locale] =
json match {
case JsString(langString) => JsSuccess(new Locale(langString))
case _ => JsError("Locale Language String Expected")
}
}
implicit val localeWrites: Writes[Locale] = new Writes[Locale] {
def writes(locale: Locale) = JsString(locale.toString)
}
How can I then use this in
implicit val myMapReads: Reads[Map[Locale, String]] = ???
implicit val myMapWrites: Writes[Map[Locale, String]] = ???
?