如何使用android的httppost发送数组

如何使用android的httppost发送数组,android,http-post,Android,Http Post,我想从android手机向服务器发送一组阵列。有没有可能这样做 我希望服务器端会出现类似的情况: $_POST['items'] = array( array('name'=>'joe', 'email'=>'joe@example.com'), array('name'=>'jane', 'email'=>'jane@example.com') ); 谢谢你的帮助 使用HttpPost向服务器发送数据,并使用json创建数组的数组。nameValue

我想从android手机向服务器发送一组阵列。有没有可能这样做

我希望服务器端会出现类似的情况:

$_POST['items'] = array(
    array('name'=>'joe', 'email'=>'joe@example.com'), 
    array('name'=>'jane', 'email'=>'jane@example.com')
);
谢谢你的帮助

使用HttpPost向服务器发送数据,并使用json创建数组的数组。nameValuePairs将携带以下数据:

HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://www.yoursite.com");

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);         
nameValuePairs.add(new BasicNameValuePair("items", jsonObject));

httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

HttpResponse response = httpclient.execute(httppost);
希望这有助于