【问题标题】:why does org.json.JSONArray constructor converts some utf-8 characters to unicode?为什么 org.json.JSONArray 构造函数将一些 utf-8 字符转换为 unicode?
【发布时间】:2016-08-04 10:21:44
【问题描述】:

对于代码JSONArray jsonArray = new JSONArray(resourceJSONStr);,如果resourceJSONStr 具有"name":"US_NE€あé¥₭",则结果为jsonArray 它的"name":"US_NE\u20acあé¥\u20ad" 为什么 org.json.JSONArray 构造函数将一些 utf-8 字符转换为 unicode?​​p>

【问题讨论】:

标签: java json unicode utf-8 org.json


【解决方案1】:

如果您通过使用 Rest-Template 从 Rest API 获取数据。所以你用那个

RestTemplate restTemplate = new RestTemplate(); restTemplate. getMessageConverters() .add(0, new StringHttpMessageConverter(Charset.forName("UTF-8")));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-07
    • 1970-01-01
    • 2012-02-22
    • 2012-07-02
    • 1970-01-01
    • 1970-01-01
    • 2011-06-05
    • 2015-10-08
    相关资源
    最近更新 更多