title: custom spray-json marshaller for a case class with Value type
body: <pre><code>case class HydraQueueMessage(tableType: HydraTableName.Value, payload: String)
  
  
  object MedusaElementFormat extends DefaultJsonProtocol {
    implicit object HydraElementFormat extends RootJsonFormat[HydraQueueMessage] {
      def write(message: HydraQueueMessage) = JsObject(
        MedusaEnum.HydraTableName.toString -&gt; JsString(message.tableType.toString),
        "payload" -&gt;  JsString(message.payload)
      )
      def read(value: JsValue) = {
        value.asJsObject.getFields("tableType", "payload") match {
          case Seq(JsString(tableType), JsString(payload)) =&gt;
            new HydraQueueMessage(tableType = tableType, payload = payload)
        }
      }
    }
  }
  </code></pre>
  
  <p>There's a type miss-match in this example, is there a cleaner way to achieve this? And still having the <code>tableType</code> as a Value and not String?</p>
  
  <p>My marshaller throws a type miss-match with the Value type, I can't marshall JsValue either. So how would I proceed to marshall the <code>HydraQueueMessage</code> case class without using a String type for <code>tableType</code>?</p>