i have a case class signup with an optional variable "secondaryEmail"
case class SignUp(firstNname : String,
var lastName: String,
var email: String,
var secondryEmail : Option[String]
)
i want to convert it to Json for that i have written a function to convert it into a Map
def putInMap(obj: SignUp) = {
val signupMap = Map(
"firstname" -> obj.firstNname,
"lastname" -> obj.lastName,
"email" -> obj.email,
"secondryemail" -> Some(obj.secondryEmail)
)
signupMap
}
Now when i try to convert it to Json like this
val signupjson = Json.toJson(putInMap(SignUp))
it gives me this error
No Json serializer found for type scala.collection.immutable.Map[String,java.io.Serializable]. Try to implement an implicit Writes or Format for this type.
is there any other way of solving this error or i have to implement an implicit Write for this?