我的php文件有这个输出:
echo json_encode(array("value0","value1","value2"));
如何在Android中将此响应作为数组获取?
HttpResponse response = httpclient.execute(httppost);
String[] resultArray = ?
我希望:
resultArray[0] --> value0
resultArray[1] --> value1
resultArray[2] --> value2
答案 0 :(得分:0)
首先使用ResponseHandler,然后您将在字符串中有响应,然后按照过程
转换为数组ResponseHandler<String> responseHandler=new BasicResponseHandler();
String responseBody = httpclient.execute(httppost, responseHandler);
JSONArray test = new JSONArray(responseBody);
String[] resultingArray = test.join(",").split(",");