首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >REST GET API调用期间的字符编码

REST GET API调用期间的字符编码
EN

Stack Overflow用户
提问于 2017-03-10 06:17:11
回答 1查看 13.3K关注 0票数 1

我有一个json数据

代码语言:javascript
复制
{

  "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."
}

获取此数据的Java代码是-

代码语言:javascript
复制
    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();

然而,我得到的结果是-

设计- AEM表单和LiveCycle ES4系统的体系结构。正在考虑为其企业级表单和文档系统使用AEM表单和LiveCycle ES4软件的IT架构师。

数据-本课程包括对Creative Cloud和服务的介绍,如库、Adobe股票、Typekit、移动应用程序和Creative

这似乎是一个如何修复this....Thanks的编码issue..Any想法

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-10 09:17:26

请尝试在请求标头中包含Accept-Charset ...希望服务器遵守这一点,并将适当的字符集作为Content-Type响应头的一部分发送。此RFC 2616声明服务器应支持Accept-Charset

Accept-Charset的可能值包括但不限于...

utf-8

iso-8859-1

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42706537

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档