Usually one would do something like this:

trait MyModelJsonProtocol extends DefaultJsonProtocol {
  implicit val feedFormat = jsonFormat2(Feed)
}
object MyModelJsonProtocol extends MyModelJsonProtocol

And use it like so:

trait MyHelloWorldRoute extends MyModelJsonProtocol = {
  val route = complete(List(Feed(...)))
}

Which should work AFAIR :-)

-- 
Cheers,
Konrad 'ktoso’ Malawski
Akka @ Typesafe

On 11 November 2015 at 14:18:57, ilya.sorokou...@gmail.com 
(ilya.sorokou...@gmail.com) wrote:

Hi Guys,

I'm trying out Akka-http on a small pet project of mine(where I'm gonna use it 
to implement some REST API) and I've stumbled upon an interesting problem with 
implicits.

So, long story short it appears that I need to add an implicit Json writer for 
each collection-entity pair that I intend to serialize into Json. 

For example, in addition to:

implicit val feedFormat = jsonFormat2(Feed)

I need to add

implicit val feedsWriter = DefaultJsonProtocol.seqFormat[Feed]

so that later in the code I can simply write 
complete(somethingThatReturnsSeqOfFeed(...)). Otherwise, it won't compile 
because there is no implicit for Seq[Feed].

Did I miss something like certain import or this is indeed the expected 
behavior?

Best Regards,
Ilya
--
>>>>>>>>>> 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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

-- 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
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