What does N in jsonFormatN in spray mean?
Asked Answered
T

1

8

I'm looking at the code of "Akka and Spray" tutorial in Typesafe's Activator, written by eigengo. I do not get where jsonFormat1, jsonFormat2, ... jsonFormatN is defined and how it does what it does.

implicit val sendMessageFormat = jsonFormat2(SendMessage)

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

Thank you.

Tl answered 1/6, 2015 at 3:43 Comment(3)
github.com/spray/spray-jsonKlug
Thank you for the link, Ashalynd. If you would write this as an answer, I would accept yours and delete mine or probably just delete this question.Tl
You're welcome, it was just a link.Klug
T
7

Basically, the N in jsonFormatN denotes the number of parameters of the class that you are trying to Marshall/Unmarshall.

An excerpt from the 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).

Tl answered 1/6, 2015 at 9:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.