title: http4s - get request body as String or InputStream
body: <p>I'm trying to define <code>HttpService</code> that receives json and parses it to case class with <code>json4s</code> library:</p>
  
  <pre><code>import org.http4s._
  import org.http4s.dsl._
  import org.json4s._
  import org.json4s.native.JsonMethods._
  
  case class Request(firstName: String, secondName: String)
  
  HttpService {
    case req @ POST -&gt; Root =&gt;
      val request = parse(&lt;map req.body or req.bodyAsText to JsonInput&gt;).extract[Request]
      Ok()
  }
  </code></pre>
  
  <p>How can I get <code>org.json4s.JsonInput</code> from <code>req.body</code> or <code>req.bodyAsText</code>?</p>
  
  <p>I know that <code>json4s</code> also have <code>StringInput</code> and <code>StreamInput</code> that inherits from <code>JsonInput</code> for using with <code>String</code> and <code>InputStream</code> so I think that I need to convert <code>req.body</code> to <code>InputStream</code> or <code>req.bodyAsText</code> to <code>String</code> but I still do not understand how.</p>
  
  <p>I'm new to Scala and I do not yet fully understand some concepts such as <code>scalaz.stream.Process</code>.</p>