Hello, 

I'm trying to write a custom Unmarshaller for my Scalajack json parser.  So 
far it looks like this:

trait ScalajackSupport {

  val sj = ScalaJack()

  implicit def sjJsUnmarshaller[T](implicit mat: 
Materializer,tt:TypeTag[T]): FromEntityUnmarshaller[T] = {

    
Unmarshaller.byteStringUnmarshaller.forContentTypes(`application/json`).mapWithCharset
 
{ (data, charset) ⇒ {

      val input:String =

        if (charset == HttpCharsets.`UTF-8`) new String(data.toArray)

        else data.decodeString(charset.nioCharset.name) // FIXME: identify 
charset by instance, not by name!

        println("INPUT: "+input)

        sj.read[T](input)

    }}

  }

}


I use it like this:


        import akka.http.scaladsl.marshallers.scalajack.ScalajackSupport._

        formFields('friend.as[Friend]) { (f) =>

          complete(s"My friend's name is ${f.name}")

        }


I fire a request at this path like this:


  curl -X POST --data 'friend={"name":"Greg","age":49}' -H "Content-Type: 
application/json" http://localhost:8082/more


This actually calls my code, but...my println shows this when run:  INPUT: 
friend={"name":"Greg","age":49}


Should I expect the input in my unmarshaller to include the "friend=" 
(param name)?  Or should it just be the value?

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to