当我记录我的名称值对时,我在控制台中得到了这个。
01-07 13:51:55.137: I/System.out(723): URL:[data={"id":"69403","timestamp":"07-01-2013 13:51:55","longitude":"-122.084095","latitude":"37.422005"}]
但我需要删除[和]。有人知道怎么做这个吗?
这是执行此操作的android代码。
json = new JSONObject();
try {
json.put("longitude", longi);
json.put("latitude", lat);
json.put("timestamp", time);
json.put("id", "69403");
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/// create StringEntity with current json obejct
try {
// StringEntity se = new StringEntity(json.toString());
List <NameValuePair> nvps = new ArrayList <NameValuePair>();
nvps.add(new BasicNameValuePair("data", json.toString()));
httpost.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
System.out.println("URL:" + httpost);
System.out.println("URL:" + nvps);
System.out.println("send about to do post");
try {
response = httpclient.execute(httpost);
System.out.println("URL:" + httpost);
} catch (ClientProtocolException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
e.printStackTrace();
} catch (IOException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
e.printStackTrace();
}