Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将Protobuf转换为JSON时禁用HTML转义_Java_Serialization_Protocol Buffers - Fatal编程技术网

Java 将Protobuf转换为JSON时禁用HTML转义

Java 将Protobuf转换为JSON时禁用HTML转义,java,serialization,protocol-buffers,Java,Serialization,Protocol Buffers,给出了一个简单的Protobuf消息 message MessageWithUrl { string url_params = 1; } 我正在做以下工作: Msg.MessageWithUrl message = Msg.MessageWithUrl .newBuilder() .setUrlParams("?key=value") .build(); String

给出了一个简单的Protobuf消息

message MessageWithUrl {

  string url_params = 1;

}
我正在做以下工作:

Msg.MessageWithUrl message = Msg.MessageWithUrl
                .newBuilder()
                .setUrlParams("?key=value")
                .build();

String json = JsonFormat.printer()
                .print(message);

System.out.println(json);
我的预期结果是:

{
  "urlParams": "?key=value"
}
相反,我得到:

{
  "urlParams": "?key\u003dvalue"
}
我知道
打印机
正在引擎盖下使用
Gson
,但我不知道如何让它接受
Gson
选项的
disableHtmlEscaping