我的 Android 应用程序出现一些奇怪的错误。这段代码似乎是对 JSON 字符串的双重编码。应该发送的是 ?{"email":"asdf@asdf.com","password":"asdf"} 或 ?%7B%22email%22:%22.....
服务器看到的是 %257B%2522email%2522:%2522 .... 这意味着服务器看到的是 %7B%22email%22:%22 .....
这使服务器感到困惑。
任何想法为什么会发生这种情况?
谢谢您的帮助
//编辑以更好地定义对象
代码:
DefaultHttpClient c = new DefaultHttpClient();
if(cookies!=null)
c.setCookieStore(cookies);
JSONObject jso = new JSONObject():
if(loginNotLogout){
jso.put("email", "email@email.com");
jso.put("password", "PassW0RD");
}
URI u = null;
if(loginNotLogout)
u= new URI("HTTP","www.website.com","/UserService",jso.toString(),"");
else
u= new URI("HTTP","www.website.com","/UserService",jso.toString(),"");
HttpGet httpget = new HttpGet(u);
HttpResponse response = c.execute(httpget);
ret.jsonString = EntityUtils.toString(response.getEntity());