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
在做微信小程序,需要生成子页面的二维码,并且在二维码中需要附带一些参数,例如:page/test/index?q=123
page/test/index?q=123
代码如下:
String path = "page/test/index?q=123"; String json = new Gson().toJson(path);
Gson 在转换成JSON的时候, = 号会变成 \u003d,导致生成的二维码不对,无法顺利跳转到具体页面。
出现这个的原因是: Gson会把html标签,转换为Unicode转义字符。
两种解决方法:
方法一:使用 JSONObject
String json = new JSONObject().fromObject(path).toString();
方法二:使用 GsonBuilder
String json = new GsonBuilder().disableHtmlEscaping().create().toJson(path); ;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在做微信小程序,需要生成子页面的二维码,并且在二维码中需要附带一些参数,例如:
page/test/index?q=123
代码如下:
Gson 在转换成JSON的时候, = 号会变成 \u003d,导致生成的二维码不对,无法顺利跳转到具体页面。
出现这个的原因是: Gson会把html标签,转换为Unicode转义字符。
两种解决方法:
方法一:使用 JSONObject
方法二:使用 GsonBuilder
The text was updated successfully, but these errors were encountered: