Hi Thibault, you are right, there's currently no built-in way to do this. To achieve it, you could e.g. copy the Jackson marshaller from the sources to use a custom media type. See here: https://github.com/akka/akka-http/blob/5932237a86a432d623fafb1e84eeeff56d7485fe/akka-http-marshallers-java/akka-http-jackson/src/main/java/akka/http/javadsl/marshallers/jackson/Jackson.java#L27-L27
Johannes On Saturday, May 6, 2017 at 8:12:06 AM UTC+2, Thibault Meyer wrote: > > Hi Greg, > > > how to do this ? I see no arguments in completeOKWithFuture > or Jackson.marshaller() to do this. I'm using Java version of akka-http. > > Thanks > > Le samedi 6 mai 2017 00:49:14 UTC+2, Greg Methvin a écrit : >> >> There is no charset parameter defined for application/json. See >> https://www.iana.org/assignments/media-types/application/json >> >> The encoding should not be determined by looking at the charset >> parameter, but rather by looking at the first four octets: >> https://tools.ietf.org/html/rfc4627#section-3 >> >> If you absolutely have to deal with non-conforming parsers, the custom >> media type is probably the right way to go. >> >> On Fri, May 5, 2017 at 2:23 PM, Alan Burlison <alan.b...@gmail.com> >> wrote: >> >>> On 05/05/17 18:42, Alex Cozzi wrote: >>> >>> funny, I was looking into this yesterday! >>>> I am by no means an expert, but I think that what it is happening is the >>>> following: >>>> application/json implies UTF-8: if you look at the MediaType class from >>>> akka http you se the declaration: >>>> >>> >>> I believe you are correct, http://www.ietf.org/rfc/rfc4627.txt says: >>> >>> 3. Encoding >>> JSON text SHALL be encoded in Unicode. The default encoding is UTF-8. >>> >>> so an explicit MIME type isn't required if the content is UTF-8 - but >>> other JSON frameworks do often seem to include the UTF-8 charset. >>> >>> As far as I know there's no "proper" way of forcing the addition of the >>> charset to the application/json content type in Akka-HTTP but it is >>> possible to hack around it: >>> >>> val ct = ContentType(MediaType.custom("application/json", >>> false).asInstanceOf[MediaType.WithOpenCharset], HttpCharset.custom("utf-8")) >>> >>> -- >>> Alan Burlison >>> -- >>> >>> >>> -- >>> >>>> 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+...@googlegroups.com. >>> To post to this group, send email to akka...@googlegroups.com. >>> Visit this group at https://groups.google.com/group/akka-user. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> *Greg Methvin* >> *Tech Lead - Play Framework* >> Lightbend, Inc. <https://www.lightbend.com/> >> >> -- >>>>>>>>>> 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 https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.