These are chat archives for hseeberger/akka-http-json

23rd
Nov 2015
Vasiliy Levykin
@vvlevykin
Nov 23 2015 09:14
Hello everyone, I have two small problems with the library.
  1. Is there a way to allow other media types in Accept, Content-Type? For example, application/vnd.collection+json, application/hal+json, or in my particular case it's application/vnd.citrix.g2wapi-v1.1+json.
  2. The generic unmarshaller seems to have a higher priority than the default ones. The problem is in a case like:
    if (response.status != StatusCodes.OK) Unmarshal(response.entity).to[String]
    Could you please suggest something?
Heiko Seeberger
@hseeberger
Nov 23 2015 10:58
@vvlevykin, wrt (1), simply call forContentTypes.
@vvlevykin, could you please elaborate on (2), because I'm not understanding the exact problem.
Vasiliy Levykin
@vvlevykin
Nov 23 2015 11:16
in (2) I mean that Unmarshal(response.entity).to[String] is only accepting JSON strings, not all strings, if the implicit unmarshaller is in scope. playJsonUnmarshaller[String] is shadowing PredefinedFromEntityUnmarshallers.stringUnmarshaller, I think.
Vasiliy Levykin
@vvlevykin
Nov 23 2015 11:22
Could you please explain (1)? I'm a bit new with akka-http. Do you mean that I can create a new unmarshaller based on playJsonUnmarshaller?
Heiko Seeberger
@hseeberger
Nov 23 2015 12:49
Yep: implicit def myUnmarshaller[A](implicit reads: Reads[A]) = PlayJsonSupport.playJsonUnmarshaller.forContentTypes(foo, bar, baz)
Vasiliy Levykin
@vvlevykin
Nov 23 2015 19:10
thanks!