Hello,
I am using Spray-json support and I have correctly implemented my json
protocol by providing implicit RootJsonFormat. Are there available
(implicit) conversions to
- lift the FromEntityUnmarshaller[MyClass] provided by Spray Json into a
FromResponseUnmarshaller[MyClass]
- lift a Un
Edmondo,
You can’t expect unmarshalling to magically unfold the Future you get back.
Hence you have to map. Or, to be more precise, you have to flatMap, because
unmarshalling returns another Future.
```
responseFuture.flatMap(Unmarshal(_).to[MyClass]) // Notice that you’re still in
Future land
Shouldn't be possible to lift the unmarshaller with an implicit conversion?
--
>> 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/gro
> On 22 Apr 2016, at 12:11, Edmondo Porcu
> wrote:
>
> Shouldn't be possible to lift the unmarshaller with an implicit conversion?
How? Do you want to block?
Heiko
--
>> Read the docs: http://akka.io/docs/
>> Check the FAQ:
>> http://doc.akka.io/docs/akka/c
I am not sure I understood, would this be blocking?
implicit def liftUnmarshaller[A,B](implicit unmarshaller:Unmarshaller[A,B]):
Unmarshaller[Future[A],B] = Unmarshaller.withMaterializer(
ec => m => a => a.flatMap{ x =>
unmarshaller.apply(x)(ec,m)
}(ec)
)
Il giorno venerdì 22 aprile 2
Hi there,
the Unmarshaller type you wrote is correct, however the infrastructure is async
in any case – inside withMaterialized you return a Future.
implicit val um: Unmarshaller[Future[String], String] = ???
val eventualString: Future[String] = Unmarshal(Future("")).to[String](um,
system.dispat