http响应中的奇怪字符

时间:2016-06-13 23:45:51

标签: java json encoding

我使用以下代码来获取SFDC数据:

HttpClient httpClient =HttpClientBuilder.create().build();
String uri = "SomeSalesForceAPI-URL";
HttpGet httpGet = new HttpGet(uri);
httpGet.addHeader(oauthHeader);
httpGet.addHeader(prettyPrintHeader);
httpGet.addHeader("Content-Type:application/json", "charset=UTF-8");
HttpResponse response = httpClient2.execute(httpGet);
String articleJSON = EntityUtils.toString(response2.getEntity());

return articleJSON;

在JSON响应中,我看到以下奇怪的字符,当我在本地Chrome上显示JSON时,我看到Â   ’      •。请查看下面附带的Response JSON。我加粗了这些奇怪的人物。另外,当我在本地chrome中查看此JSON的视图来源时,我看到了这一点:Â&nbsp

感谢。

<p></p> <h2>Welcome to GoToAssist!</h2><div style=\"float: right; background-color: #f5f5f5; margin-left: 0px; width: 200px; height: 150px;\"> <p style=\"font-weight: bold; font-style: italic; font-size: 11pt;\">Resources: </p> <p>• <a href=\"http://support.citrixonline.com/en_US/gotoassistremotesupport/all_files/G2ARS010012\" target=\"_blank\">Remote Support Quick Start</a></p> <p>•

具体而言,•Â

1 个答案:

答案 0 :(得分:0)

对于utf-8,可能有些字符编码不正确。 我认为应该是'和'应该是“ 再次检查您的编码并尝试使用以下方法

EntityUtils.toString(httpEntity, HTTP.UTF_8);