【发布时间】:2018-07-26 08:26:02
【问题描述】:
我在 Java 类中有一个授权枚举: 公共枚举 FinalResponse {
THING_1("Thing1") {
@Override
String getDescription() {
return "Based on what you've told us so far, it’s likely ; (it goes on)
}
@Override
String getApplyUrl() {
return "https://www.theinternet.com";
}
},
当我从以下类调用 getDescription 时:
class FinalResponseMaker {
FinalResponseMaker() {}
static String getResponse(FinalResponse response) {
def output = JsonOutput.toJson([[
code: response.getCode(),
description: response.getDescription(),
apply_url: response.getApplyUrl()]])
JsonOutput.prettyPrint(output)
}
}
此代码的输出包含字符串
it\u2019s likely,
即由于某种原因,“it's”中的反逗号已变成其 unicode 字符。
为什么?我怎样才能让这种情况停止发生?
我尝试过使用
def pretty = JsonOutput.prettyPrint(output)
def unescaped = JsonOutput.unescaped(pretty)
return unescaped
但这不起作用。任何帮助都会很棒,谢谢
【问题讨论】: