I am consuming the JSON below,
{
"@context": "Testingcontext",
"@type": "Testingtype",
"actor": "Testingactor"
}
for which I am creating a case class in scala:
case class LoggedInAction(`@context`: String,`@type`:String,actor:String)
How can I use special character like @
, &
in a case class? Also, how to use such case class fields?
答案 0 :(得分:2)
正如您在示例中所做的那样:
scala> case class LoggedInAction(`@context`: String,`@type`:String,actor:String)
defined class LoggedInAction
scala> val example = LoggedInAction("context", "type", "actor")
example: LoggedInAction = LoggedInAction(context,type,actor)
scala> example.`@context`
res0: String = context