title: Scala (spray) json serialization and deserialization issue
body: <p>I'm using my own implicit implementation of JSON serializer and deserializer for my case object</p>
  
  <p>My case class looks like (it's just a code snippet)</p>
  
  <pre><code>sealed trait MyTrait
  
  case object MyCaseClass extends MyTrait
  </code></pre>
  
  <p>I want to write my own ser. and deser. of JSON for MyTrait</p>
  
  <pre><code>implicit val myTraitFormat = new JsonFormat[MyTrait] {
    override def read(json: JsValue): MyTrait = json.asJsObject.getFields("value") match {
      case Seq(JsString("TEST")) ⇒ MyCaseClass
      case _ ⇒ throw new DeserializationException(s"$json is not a valid extension of my trait")
    }
    override def write(myTrait: MyTrait): JsValue = {
      myTrait match {
        case MyCaseClass =&gt; JsObject("value" -&gt; JsString("TEST"))
      }
    }
  }
  </code></pre>
  
  <p>Now my test is failing by throwing DeserializationException:</p>
  
  <pre><code>"The my JSON format" when {
    "deserializing a JSON" must {
      "return correct object" in {
        val json = """{"value": "TEST"}""".asJson
        json.convertTo[MyTrait] must equal (MyCaseClass)
      }
    }
  }
  </code></pre>
  
  <p>Obviously <code>json.asJsObject.getFields("value")</code>can not be matched to <code>Seq(JsString("TEST"))</code>. Maybe this is related to using traits?
  But I have found example on official spray-json site <a href="https://github.com/spray/spray-json#providing-jsonformats-for-other-types" rel="nofollow">https://github.com/spray/spray-json#providing-jsonformats-for-other-types</a></p>
  
  <p>Any ideas how to properly match on field in JsObject?</p>
  
  <p>Thanks!
  Best</p>