title: Difficulty serializing immutable.Map with spray-json
body: <p>Apologies in advance for cross-posting: I submitted this question to the spray user list, but the list appears to be moderated, and nobody seems to be home.  Hopefully SO is a better venue.</p>
  
  <p>I am having difficulty serializing complex data structures with <code>spray-json</code>.  For example, a simple <code>immutable.Map[String,String]</code> works fine, but an <code>immutable.Map[String,Foo]</code>, where <code>Foo</code> is a case class that I define does not.  The documentation left me with the impression that I simply needed to define a <code>JsonFormat</code> for <code>Foo</code> and I'd be ready to roll.</p>
  
  <p>Here's some sample code:</p>
  
  <pre><code>import spray.json._
  import DefaultJsonProtocol._
  
  case class Foo(hi: String)
  
  object FooProtocol extends DefaultJsonProtocol {
    implicit val fooFormat: JsonFormat[Foo] = jsonFormat1(Foo)
  }
  import FooProtocol._
  
  object Thing {
    def toSomething = {
      Map("foo" -&gt; Foo("bar"), "baz" -&gt; Foo("quux")).toJson
    }
  }
  </code></pre>
  
  <p>Which yields the following compiler error:</p>
  
  <pre><code>[info] Compiling 1 Scala source to C:\spraytest\target\scala-2.10\classes...
  [error] C:\spraytest\src\main\scala\Foo.scala:12: Cannot find JsonWriter or JsonFormat type class for scala.collection.immutable.Map[String,Foo]
  [error]     Map("foo" -&gt; Foo("bar"), "baz" -&gt; Foo("quux")).toJson
  [error]                                                    ^
  [error] one error found
  [error] (compile:compile) Compilation failed
  [error] Total time: 5 s, completed Jun 26, 2014 11:40:26 AM
  </code></pre>
  
  <p>I'm stumped.</p>