我想将Jackson's ObjectNode
的内容写入一个字符串,其中UTF-8字符被写成ASCII(Unicode转义).
Here is a sample method:
private String writeUnicodeString() {
ObjectMapper mapper = new ObjectMapper();
ObjectNode node = mapper.getNodeFactory().objectNode();
node.put("field1", "Maël Hörz");
return node.toString();
}
By default, this outputs:
{"field1":"Maël Hörz"}
What I would like it to output is:
{"field1":"Ma\u00EBl H\u00F6rz"}
How can I accomplish this?