Can';t从php页面接收JSON对象

Can';t从php页面接收JSON对象,php,android,json,Php,Android,Json,我有一个非常简单的php代码,如下所示: <?php $myArr = array("John", "Mary", "Peter", "Sally"); echo json_encode($myArr); ?> 在我的android studio中,我有以下asynctask类,它将生成一个名为result的字符串: public class UserLoginTask extends AsyncTask<Void, Void, Boolean> { @Ov

我有一个非常简单的php代码,如下所示:

<?php
$myArr = array("John", "Mary", "Peter", "Sally");
echo json_encode($myArr);
?>

在我的android studio中,我有以下asynctask类,它将生成一个名为result的字符串:

public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
    @Override
    protected Boolean doInBackground(Void... params) {
        try {
            result = HttpManager.SendData(dataPack);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }

    @Override
    protected void onPostExecute(final Boolean success) {
            Toast.makeText(c,result,Toast.LENGTH_SHORT).show();
        mAuthTask = null;
    }

    @Override
    protected void onCancelled() {
        mAuthTask = null;
    }
}
public类UserLoginTask扩展异步任务{
@凌驾
受保护的布尔doInBackground(Void…params){
试一试{
结果=HttpManager.SendData(数据包);
}捕获(例外e){
e、 printStackTrace();
}
返回true;
}
@凌驾
受保护的void onPostExecute(最终布尔值成功){
Toast.makeText(c,result,Toast.LENGTH_SHORT).show();
mAuthTask=null;
}
@凌驾
受保护的void onCancelled(){
mAuthTask=null;
}
}
和使用结果字符串类的jsonparser,如下所示:

private String[] jSonParser(String s){
    String[] mlist={""};
    mlist[0]="no users found";
    if (s != null) {
        try {
            JSONObject o = new JSONObject(result);
            JSONArray a = o.getJSONArray("types");
            for (int i = 0; i < a.length(); i++) {
                mlist[i]=a.getString(i);
            }
            Toast.makeText(c, "JSON recieved!", Toast.LENGTH_SHORT).show();
        } catch (JSONException e) {
            e.printStackTrace();
            Toast.makeText(c, "JSONException", Toast.LENGTH_SHORT).show();
        }
    }
    else {
        Toast.makeText(c, "Couldn't get any JSON data.", Toast.LENGTH_SHORT).show();
    }
    return mlist;
}
private String[]jSonParser(字符串s){
字符串[]mlist={”“};
mlist[0]=“未找到用户”;
如果(s!=null){
试一试{
JSONObject o=新的JSONObject(结果);
JSONArray a=o.getJSONArray(“类型”);
对于(int i=0;i

但是我一直收到JSONException。我做错了什么?

我不确定这是否是原因,但通过PHP的
函数将
内容类型设置为
应用程序/json
可能没有什么坏处。你能详细说明一下plz吗?你知道我甚至验证了我的json字符串,它似乎是一个基本的json字符串,我无法解决这个问题。