We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JDK版本: openjdk_8_401 hutool版本: 5.8.27
xml转jsonobject,xml标签中的字符串&被转成了&,可以做配置不要转吗?
代码这样写的
String inPara= "<ROOT><ID>002317479934367853</ID><CONTENT>asdfadf&21sdgzxv&aasfasf</CONTENT></ROOT>"; cn.hutool.json.JSONObject jsonObject2 = XML.toJSONObject(inPara, true);
第二个参数传true的原因是希望数字不要被转成数字型,需要全部都是字符串型
The text was updated successfully, but these errors were encountered:
这个转换是没问题的。
我简化你的XML:
<CONTENT>&</CONTENT>
因为&是保留字符,因此在XML中需要转义,变成&,这样在解析时会被反解析为&。
&
&
你如果想显示原本的内容&,那你的内容必须为:
<CONTENT>&amp;</CONTENT>
或者使用CDATA方式表示原始字符串:
CDATA
<![CDATA[&]]>
在你的例子中为:
String inPara= "<ROOT><ID>002317479934367853</ID><CONTENT><![CDATA[asdfadf&21sdgzxv&aasfasf]]></CONTENT></ROOT>"; JSONObject json = XML.toJSONObject(inPara, true);
Sorry, something went wrong.
No branches or pull requests
版本情况
JDK版本: openjdk_8_401
hutool版本: 5.8.27
问题描述
xml转jsonobject,xml标签中的字符串&被转成了&,可以做配置不要转吗?
代码这样写的
第二个参数传true的原因是希望数字不要被转成数字型,需要全部都是字符串型
The text was updated successfully, but these errors were encountered: