我必须使用封装在 POST 请求中的 JSONObject 将带有 DES 的加密密码发送到 WebServer。问题是,当我这样做时:
JSONObject jsonLogin = new JSONObject();
try{
jsonLogin.put("username", usernameS);
jsonLogin.put("password", passwordEncrypted);
}catch (JSONException e){
e.printStackTrace();
}
如果我打印 JSON 对象的内容:
System.out.println("JSON to Server = "+jsonLogin);
结果是:
JSON to Server = {"password":"Qxw\/h16PVdE=\n","username":"XXXXXXXX@gmail.com"}
但正确的密码是Qxw/h16PVdE=
,所以服务器无法识别它。
我发现了一些建议使用:string.replaceAll("\/","/");
但我想实施一个干净的解决方案。请给我任何建议。