Hi Michel,
That's not so straightforward because it relies on runtime types, so we'll have to create a custom serializer to dispatch to other serializers as appropriate. This works, but you'll need to add cases for all types you want to serialize:
implicit val anySerializer: rapture.data.Serializer[Any, Json] =
Json.serializer[Json].contramap {
case s: String => Json(s)
case i: Int => Json(i)
case d: Double => Json(d)
}
val json = Json(Map("foo" -> "bar", "baz" -> 42))
That might look very redundant with the right-hand side of all the cases being the same, but each of those calls to `Json(foo)` is pulling in a different implicit `Serializer` of its own based on the type matched on the LHS.
Does that work?
Cheers,
Jon