{"action":"created","issue":{"url":"https://api.github.com/repos/akka/akka/issues/18389","labels_url":"https://api.github.com/repos/akka/akka/issues/18389/labels{/name}","comments_url":"https://api.github.com/repos/akka/akka/issues/18389/comments","events_url":"https://api.github.com/repos/akka/akka/issues/18389/events","html_url":"https://github.com/akka/akka/issues/18389","id":104510528,"number":18389,"title":"spray-json support unmarshaller charset problem","user":{"login":"fehmicansaglam","id":446202,"avatar_url":"https://avatars.githubusercontent.com/u/446202?v=3","gravatar_id":"","url":"https://api.github.com/users/fehmicansaglam","html_url":"https://github.com/fehmicansaglam","followers_url":"https://api.github.com/users/fehmicansaglam/followers","following_url":"https://api.github.com/users/fehmicansaglam/following{/other_user}","gists_url":"https://api.github.com/users/fehmicansaglam/gists{/gist_id}","starred_url":"https://api.github.com/users/fehmicansaglam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fehmicansaglam/subscriptions","organizations_url":"https://api.github.com/users/fehmicansaglam/orgs","repos_url":"https://api.github.com/users/fehmicansaglam/repos","events_url":"https://api.github.com/users/fehmicansaglam/events{/privacy}","received_events_url":"https://api.github.com/users/fehmicansaglam/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/akka/akka/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/akka/akka/labels/t:http","name":"t:http","color":"CCCCCC"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/akka/akka/milestones/54","html_url":"https://github.com/akka/akka/milestones/http-1.1","labels_url":"https://api.github.com/repos/akka/akka/milestones/54/labels","id":1208890,"number":54,"title":"http-1.1","description":"","creator":{"login":"ktoso","id":120979,"avatar_url":"https://avatars.githubusercontent.com/u/120979?v=3","gravatar_id":"","url":"https://api.github.com/users/ktoso","html_url":"https://github.com/ktoso","followers_url":"https://api.github.com/users/ktoso/followers","following_url":"https://api.github.com/users/ktoso/following{/other_user}","gists_url":"https://api.github.com/users/ktoso/gists{/gist_id}","starred_url":"https://api.github.com/users/ktoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktoso/subscriptions","organizations_url":"https://api.github.com/users/ktoso/orgs","repos_url":"https://api.github.com/users/ktoso/repos","events_url":"https://api.github.com/users/ktoso/events{/privacy}","received_events_url":"https://api.github.com/users/ktoso/received_events","type":"User","site_admin":false},"open_issues":53,"closed_issues":60,"state":"open","created_at":"2015-07-15T09:32:18Z","updated_at":"2015-11-01T10:42:25Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2015-09-02T15:37:49Z","updated_at":"2015-11-02T14:12:12Z","closed_at":"2015-09-03T09:16:44Z","body":"Hi,\r\n\r\nI have experienced a strange problem and it seems to be a bug. Below is the request json that I send to a service:\r\n\r\n```json\r\n{\"title\":\"ÇatÇat Kitapları\",\"parentName\":\"Çocuk Kitapları\"}\r\n```\r\n\r\nThis json is decoded as:\r\n\r\n```json\r\n{\"title\":\"Ã�atÇat Kitapları\",\"parentName\":\"Ã�ocuk Kitapları\"}\r\n```\r\n\r\nBut more interestingly when I put a character before `Ç` as below:\r\n\r\n```json\r\n{\"title\":\"aÇatÇat Kitapları\",\"parentName\":\"aÇocuk Kitapları\"}\r\n```\r\n\r\nIt is decoded perfectly as below:\r\n\r\n```json\r\n{\"title\":\"aÇatÇat Kitapları\",\"parentName\":\"aÇocuk Kitapları\"}\r\n```\r\n\r\nAs I saw some very strange things are happening here I tried to debug the problem. Below is the code snippet that seems to be responsible for JsonParser creation in SprayJsonSupport.scala\r\n\r\n```scala\r\nUnmarshaller.byteStringUnmarshaller.forContentTypes(`application/json`).mapWithCharset { (data, charset) ⇒\r\n  val input =\r\n    if (charset == HttpCharsets.`UTF-8`) ParserInput(data.toArray)\r\n    else ParserInput(data.decodeString(charset.nioCharset.name)) // FIXME: identify charset by instance, not by name!\r\n  JsonParser(input)\r\n}\r\n```\r\n\r\nSo I tried changing the related line to this:\r\n\r\n```scala\r\n if (charset == HttpCharsets.`UTF-8`) ParserInput(data.utf8String)\r\n```\r\n\r\nAnd everything worked perfectly. So am I doing smth wrong or is there a problem in spray-json or maybe in ByteString?\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/akka/akka/issues/comments/153027487","html_url":"https://github.com/akka/akka/issues/18389#issuecomment-153027487","issue_url":"https://api.github.com/repos/akka/akka/issues/18389","id":153027487,"user":{"login":"sirthias","id":135347,"avatar_url":"https://avatars.githubusercontent.com/u/135347?v=3","gravatar_id":"","url":"https://api.github.com/users/sirthias","html_url":"https://github.com/sirthias","followers_url":"https://api.github.com/users/sirthias/followers","following_url":"https://api.github.com/users/sirthias/following{/other_user}","gists_url":"https://api.github.com/users/sirthias/gists{/gist_id}","starred_url":"https://api.github.com/users/sirthias/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sirthias/subscriptions","organizations_url":"https://api.github.com/users/sirthias/orgs","repos_url":"https://api.github.com/users/sirthias/repos","events_url":"https://api.github.com/users/sirthias/events{/privacy}","received_events_url":"https://api.github.com/users/sirthias/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T14:12:12Z","updated_at":"2015-11-02T14:12:12Z","body":"@fehmicansaglam One question: Somehow I cannot reproduce the parsing problem you reported here.\r\nWhat spray-json version were you using?"}}