spray 中的 jsonFormatN 中的 N 是什么意思?

What does N in jsonFormatN in spray mean?

我在看 Typesafe 的 Activator 中“Akka and Spray”教程的代码,由 eigengo 编写。我不明白 jsonFormat1、jsonFormat2、... jsonFormatN 的定义以及它是如何工作的。

implicit val sendMessageFormat = jsonFormat2(SendMessage)

上面的代码片段在 scala > api > MessengerService.scala

谢谢。

基本上,jsonFormatN 中的 N 表示您尝试 Marshall/Unmarshall 的 class 的参数数量。

摘自link posted by Ashalynd

The jsonFormatX methods reduce the boilerplate to a minimum, just pass the right one the companion object of your case class and it will return a ready-to-use JsonFormat for your type (the right one is the one matching the number of arguments to your case class constructor, e.g. if your case class has 13 fields you need to use the jsonFormat13 method).