我必须使用封装在POST请求中的JSONObject将带有DES的加密密码发送到WebServer。问题是,当我这样做:Android - Put方法JSONObect在字符串中查找'/'时添加''
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":"[email protected]"}
,但正确的密码是Qxw/h16PVdE=
,所以服务器无法识别它。
我发现了一些暗示使用的建议:string.replaceAll("\/","/");
但我想实施一个干净的解决方案。 请给我任何建议。
谁在密码末尾添加了“\ n”? –
我刚刚看到“\ n”..是添加'\'和'\ n'的put方法。 passwordEncrypted的内容是:Qxw/h16PVdE = – Paolo