What does N mean in jsonFormatN in spray?

I am looking at the " Akka and Spray " tutorial in the Activator Activator written by eigengo. I don't understand where jsonFormat1, jsonFormat2, ... jsonFormatN are defined and how it does what it does.

implicit val sendMessageFormat = jsonFormat2(SendMessage)

The above snippet is in scala> api> MessengerService.scala

Thank.

+3


source to share


1 answer


Basically, N

in jsonFormatN

denotes the number of parameters of the class you are trying Marshall / Unmarshall .

An excerpt from the link posted by Ashalynd :



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

+3


source







All Articles