我需要我的應用程序發送ArrayList<String[]>
到PHP,我有這樣調用服務:的Android的ArrayList <String[]>到PHP
ArrayList<String[]> Items = new ArrayList<String[]>();
(...)
JSONObject JSONSend= new JSONObject();
JSONSend.put("Items", Items);
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000);
HttpResponse response;
HttpPost post = new HttpPost(SERVICE);
post.setHeader("json", JSONSend.toString());
StringEntity se = new StringEntity(JSONSend.toString());
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/json"));
post.setEntity(se);
response = client.execute(post);
和PHP服務:
$data = file_get_contents('php://input');
$json = json_decode($data);
$Items = $json->{'Items'};
error_log($Items);
和PHP返回這個:
[[Ljava.lang.String;@413e2fd0, [Ljava.lang.String;@413a2940, [Ljava.lang.String;@4139df18, [Ljava.lang.String;@4141b5b0, [Ljava.lang.String;@413931c8, [Ljava.lang.String;@41348b40, [Ljava.lang.String;@41393928]
$ ServMade的類型是字符串,所以我該如何照顧第e數據作爲一個數組在PHP?我錯過了什麼嗎?
這看起來應該正常工作:-) – shadyyx
我用「JSONSend.put(」Items「,tmp));」相反,它的工作,因爲我想,謝謝 – Joaolvcm