title: How to apply toJson to instance of a case class using spray-json library
body: <p>Registration.scala</p>
  
  <pre><code>package model
  
  import akka.actor.Actor
  import spray.json._
  import DefaultJsonProtocol._
  
  case class Registration(
    system: String, 
    identity: String)
  
  object RegistrationProtocol extends DefaultJsonProtocol {
    implicit val adsRegistrationFormat = jsonFormat2(Registration)
  }
  </code></pre>
  
  <p>RegistrationService.scala</p>
  
  <pre><code>import akka.actor.{Props, ActorLogging, Actor}
  import model.Registration
  
  object RegistrationsService {
    case class PostRegistrationMessage(registration: Registration)
  
    def props(property: String) = Props(classOf[RegistrationsService], property)
  }
  
  class RegistrationsService(property: String) extends Actor with ActorLogging {
    import RegistrationsService._
  
    def receive = {
      case PostRegistrationMessage(registration) =&gt; {
        import model.RegistrationProtocol._
  
        val json = registration.toJson
  
      }
    }
  }
  </code></pre>
  
  <p>Can anyone help me understand why this is failing with compilation error "value toJson is not a member of model.Registration" and how to fix it. It if failing in the last line of the code above, which is "<strong>val json = registration.toJson</strong>"</p>