Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我将 Gson 函数toJson用于=,>和<运算符,并在最终字符串中将它们解释为\u003e.
toJson
=
>
<
\u003e
是否有我需要添加或处理的特殊功能?
您应该禁用 HTML escaping,这是一个说明它的示例:
Gson gson1 = new Gson(); String s1 = gson1.toJson("<>"); Gson gson2 = new GsonBuilder().disableHtmlEscaping().create(); String s2 = gson2.toJson("<>");
s1: "\u003c\u003e"
s2:“<>”