如何告诉Gson解码器正确解码

问题描述

我在WebClient(org.springframework.web.reactive.function.client.WebClient)中使用了本帖子https://stackoverflow.com/a/60855905/7265913中的Gson编码/解码器/编码器

那很好,直到现在。我试图从RestService接收fxml。服务响应如下(提琴手):

HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
Date: Fri,02 Oct 2020 10:01:00 GMT
Content-Length: 394

"\u003c?xml version\u003d\"1.0\" encoding\u003d\"UTF-8\"?\u003e\u003c?import javafx.scene.layout.AnchorPane?\u003e\u003cAnchorPane maxHeight\u003d\"-Infinity\" maxWidth\u003d\"-Infinity\" minHeight\u003d\"-Infinity\" minWidth\u003d\"-Infinity\" prefheight\u003d\"400.0\" prefWidth\u003d\"600.0\" xmlns\u003d\"http://javafx.com/javafx/11.0.1\" xmlns:fx\u003d\"http://javafx.com/fxml/1\" /\u003e"

问题是,解码器根本不转换输入的String。 Unicode字符仍然保留(例如\u003c而不是<)和所有转义字符(\"UTF-8\"而不是"UTF-8"或所有换行符\n)。有人可以告诉我要更改什么吗? 当然,我可以自己转换String,但是我认为应该由Gson / Decoder完成,但是我不知道如何实现。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)