It is converting a Json object into Scala object and vice versa. (__ \ "event")
means "event" element of Json object, and ~
means joining the elements into a tuple.
Trying to understand scala code in Activator reactive maps examples in Play2
-
21-06-2023 - |
题
I'm trying to understand the following piece of code in the Activator reactive maps example. I would appreciate if someone can explain the ( __ \ "event")
and ~
part of code.
object UserPositions {
implicit def userPositionsFormat: Format[UserPositions] = (
(__ \ "event").format[String] ~
(__ \ "positions").format[FeatureCollection[LatLng]]
).apply({
case ("user-positions", positions) => UserPositions(positions)
}, userPositions => ("user-positions", userPositions.positions))
}
解决方案
不隶属于 StackOverflow