title: spray / akka http json marshalling case classes as values
body: <p>In spray / akka http I can marshal/unmarshal a case class like so:</p>
  
  <pre><code>case class Latitude(value:Double)
  object Latitude extends DefaultJsonProtocol with SprayJsonSupport {
    implicit val LatitudeFormat = jsonFormat1(Latitude.apply)
  }
  </code></pre>
  
  <p>However this will marshal a <code>Latitude(42)</code> to an object <code>{value:42}</code>. I rather want it to be marshalled to just a JsNumber <code>42</code>. To do so I did the following:</p>
  
  <pre><code>case class Latitude(value:Double)
  object Latitude extends DefaultJsonProtocol with SprayJsonSupport {
    implicit object LatitudeFormat extends RootJsonFormat[Latitude] {
      def write(lat: Latitude) = lat.value.toJson
      def read(value: JsValue) = ??? //too much code with decent error handling, but working
    }
  }
  </code></pre>
  
  <p>However I don't want to do this for every "simple value case class".
  My goal is to e.g. create a function (or maybe a macro) that works exactly like spray's <code>jsonFormat1</code> except it does not write/read objects but simple values, depending on the case class I use it on.</p>
  
  <p>Unfortunately there does not seem to be any way to extend or compose the jsonRootFormat object that is returned from the jsonFormat1 function. The function itself seems to use already deprecated stuff (like <code>ClassManifest</code>) so I'm not sure if I want to copy and adjust it for my needs. What is my best option in this situation to get/create such a simple case class to JsValue function?</p>