Similar to this, I need the string equivalent of a net.sf.json.JSON object expressed entirely in ASCII characters.
new JSONObject().put("JSON", "帮").toString();
to return
{"JSON":"\u5E2E"}
not
{"JSON":"帮"}
Are you looking for a JSONObject based solution or normal java solution?
I am not sure is JsonObject have any such functionality. But a vaniall java based approach would be
public static void main(String[] args){
String s = "帮";
String s1 = "";
for (int i = 0; i < s.length(); i++)
s1 = s1+"\\u" + Integer.toHexString(s.charAt(i) | 0x10000).substring(1);
System.out.println(s1);
}