【发布时间】:2010-05-17 02:18:18
【问题描述】:
作为我们正在开发的应用程序的一部分(使用 android 客户端和 Django 服务器),一个包含用户名和密码的 json 对象从 android 客户端发送到服务器,如下所示
HttpPost post = new HttpPost(URL);
/*Adding key value pairs */
json.put("username", un);
json.put("password", pwd);
StringEntity se = new StringEntity(json.toString());
post.setEntity(se);
response = client.execute(post);
响应是这样解析的
result = responsetoString(response.getEntity().getContent()); //Converts response to String
jObject = new JSONObject(result);
JSONObject post = jObject.getJSONObject("post");
username = post.getString("username");
message = post.getString("message");
希望一切都好。 在 Django 服务器中解析或发送 JSON 响应时出现问题。最好的方法是什么?
我们尝试使用 SimpleJSON,结果发现并没有那么简单,因为我们没有找到任何好的教程或相同的示例代码?是否有任何类似的 python 函数来获取、放置和选择 java 的 JSON?任何帮助将不胜感激..
【问题讨论】:
标签: android django json parsing