2017-03-09 3 views
1

내가 문자 인코딩 REST 동안 API 호출

HttpClient httpClient = new HttpClient(); 
    HttpMethod method = new GetMethod(url); 
    method.addRequestHeader("accept", "application/json"); 
    method.addRequestHeader("X-API-Key", apiKey); 
    method.addRequestHeader("certificate", certificate); 
    int status = httpClient.executeMethod(method); 
    JSONObject data = (JSONObject) JSONValue.parse(method.getResponseBodyAsString()); 
    String desc = data.get("description").toString(); 
    String data = data.get("title").toString(); 
그러나 나는

내림차순 된 직후 결과를 얻을 IS-이 데이터를 얻을 수있는 JSON 데이터

{ 

    "description": "Architectures of Adobe\ufffds AEM Forms and LiveCycle ES4 systems. IT architects who are considering Adobe\ufffds AEM Forms and LiveCycle ES4 so\ufffdftware for their enterprise\ufffds form and document systems.", 

    "title" : "This course includes an introduction to the Creative Cloud and services such as Libraries, Adobe Stock, Typekit, Mobile Apps, and Bēhance." 
} 

자바 코드가를 GET - Adobe의 AEM Forms 및 LiveCycle ES4 시스템의 아키텍처 Adobe의 AEM Forms 및 LiveCycle ES4 소프트웨어를 엔터프라이즈 형식 및 문서 시스템으로 고려중인 IT 설계자

데이터 -이 과정은이 문제를 해결하는 방법 인코딩 issue..Any 아이디어로 보인다 크리에이티브 클라우드와 같은 라이브러리, 어도비 증권, Typekit, 모바일 앱 및 BÄhance

등의 서비스에 대한 소개가 포함되어 있습니다. ... 감사합니다

+0

왜 텍스트가'\ ufffd'() 대체 문자가 않습니다 그게 처음부터? 이 시점까지 문자 집합 변환 문제가있는 것처럼 보입니다. – Andreas

+0

Json 데이터가 제 3 자 API에서이 형식으로 제공됩니다 ....이 .... 적절한 인코딩을 할 필요가 있다고 생각하지만 .... 어떻게 .......... 의도 된 출력 desc는 Adobe의 AEM Forms 및 LiveCycle ES4 시스템의 아키텍처 여야합니다. 기업의 양식 및 문서 시스템을 위해 Adobe의 AEM Forms 및 LiveCycle ES4 소프트웨어를 고려중인 IT 설계자 – Tapan

답변

0

요청 헤더에 Accept-Charset을 포함 시키십시오 ... 서버가 이것을 기꺼이 받아 들여 Content-Type 응답 헤더의 일부로 적절한 charset을 전송하십시오.이 RFC 2616은 Accept-Charset 서버가 준수해야합니다.

Accept-Charset inc에 가능한 값은 다음과 같습니다. lude 이에 국한되지 않습니다 ...

UTF-8

ISO-8859-1

는 참조 - https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Charset