如何让我的的JSONObject的EN code中的UTF-8字符UNI code中的的toString()像PHP的json_en code? [英] How do I make the toString() of the JSONObject encode the UTF-8 characters to unicode like in json_encode of PHP?
问题描述
在爪哇(使用Android设备),这里有code线:
In Java (using for Android), here are the code lines:
org.json.JSONObject array = new org.json.JSONObject("{\"value\":\"aész\"");
System.out.println("RES: " + array.toString());
输出我想:
RES:{值:一个\\ u00e9sz}
RES: {"value":"a\u00e9sz"}
当它实际上是:
RES:{值:aész}
RES: {"value":"aész"}
我如何做的JSONObject 的toString()
方法返回JSON字符串带在UTF-8的特殊字符UNI code值codeD,像 json_en code(阵列(值,aész));
How do I make the JSONObject toString()
method return the JSON String encoded with unicode values in the UTF-8 special characters, like the json_encode(array("value", "aész"));
先谢谢了。
推荐答案
这听起来更像是瓶子的问题。 JSONObject的是在不同的开源库使用的类。下载此瓶 JSON-RPC-1.0.jar
It sounds more like jar issue. JsonObject is the class used across various open source libraries. Download this jar json-rpc-1.0.jar
试试这个:
JSONObject json = new JSONObject();
json.put("value", "aész");
System.out.println(json.toString());
生产:
{"Name":"u00e9sz"}
这篇关于如何让我的的JSONObject的EN code中的UTF-8字符UNI code中的的toString()像PHP的json_en code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!