title: How to receive JSON object in Ktor?
body: <p>I have data class defined, configured gson and created rout to handle post request as follows:</p>
  
  <pre><code>data class PurchaseOrder(val buyer: String, val seller: String, 
  val poNumber: String, val date: String,
                       val vendorReference: String)
  
   install(ContentNegotiation) {
      gson {
          setDateFormat(DateFormat.LONG)
          setPrettyPrinting()
      }
  
  
      post("/purchaseOrder"){
          val po = call.receive&lt;PurchaseOrder&gt;()
          println("purchase order: ${po.toString()}")
          call.respondText("post received", contentType = 
          ContentType.Text.Plain)
  </code></pre>
  
  <p>the following JSON is sent in POST request</p>
  
  <pre><code>{
  "PurchaseOrder" : {
  "buyer": "buyer a",
  "seller": "seller A",
  "poNumber": "PO1234",
  "date": "27-Jun-2018",
  "vendorReference": "Ref1234"
  }
  }
  </code></pre>
  
  <p>The output shows all nulls.</p>
  
  <pre><code>purchase order: PurchaseOrder(buyer=null, seller=null, poNumber=null, 
  date=null, vendorReference=null)
  </code></pre>
  
  <p>Reading data from call.request.receiveChannel() does show correct JSON. So I am receiving the data but call.receive() does not seem to produce expected results.</p>
  
  <p>Got JSON manually and tried to create PurchaseOrder as follows bu no luck:</p>
  
  <pre><code>val channel = call.request.receiveChannel()
          val ba = ByteArray(channel.availableForRead)
          channel.readFully(ba)
          val s = ba.toString(Charset.defaultCharset())
  
          println(s) // prints JSON
  
          val gson = Gson()
          val po = gson.fromJson(s, PurchaseOrder::class.java)
  
          println("buyer = ${po.buyer}"  //prints null
  </code></pre>