2013-10-30 63 views

回答

1
JSONObject json = new JSONObject("{"data1":"data1data","data2":"data2data"}"); 
JSONArray array = new JSONArray(); 
array.put(json); 

把那個陣列中的HTTP調用,後期例如:

DefaultHttpClient client = new DefaultHttpClient(); 
HttpPut put = new HttpPut(uri); 
put.setEntity(new StringEntity(array.toString())); 
put.setHeader("content-type", "application/json"); 
httpResponse = client.execute(put); 
+0

喬恩工作,你可以指導我怎麼傳遞到一個web服務通過因爲這會變成錯誤** params.add(新的BasicNameValuePair(「數組」,數組)); ** – androidBeckhamania

+0

如果答案是正確的標記爲答案,請。首先,如果要傳遞一個名爲array的參數,請使用new BasicNameValuePair(「array」,array.toString())。但可能你只是想以JSON的形式傳遞數組。我將用一個例子編輯我的答案。 –

相關問題