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.burli...@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/c
>>>>>>>>>>> urrent/additional/faq.html
>>>>>>>>>>>      Search the archives: https://groups.google.com/grou
>>>>>>>>>>> p/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.
>



-- 
*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.

Reply via email to