解析错误 JSON Android-Facebook

Error parsing JSON Android-Facebook

我正在尝试使用 Android 应用程序从 Facebook 获取我自己的个人资料照片。 我使用以下代码:

private void getProfilePicture()
    {       
        Bundle params = new Bundle();
        params.putBoolean("redirect", false);
        params.putString("height", "200");
        params.putString("type", "normal");
        params.putString("width", "200");
        /* make the API call */
        new Request(
            Session.getActiveSession(), "/me/picture", params, HttpMethod.GET,
            new Request.Callback()
            {
                @Override
                public void onCompleted(Response response)
                {
                    GraphObject graphObject = response.getGraphObject();
                    if (graphObject != null)
                    {
                        JSONObject jsonObject = graphObject.getInnerJSONObject();
                        try
                        {
                            JSONArray array = jsonObject.getJSONArray("data");
                        }
                        catch (JSONException e)
                        {
                            e.printStackTrace();
                        }
                    }               
                }
            }
        ).executeAsync();
    }

在行 JSONArray array = jsonObject.getJSONArray("data"); 中抛出异常:

org.json.JSONException: Value {"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xaf1\/v\/t1.0-1\/p200x200\/10420230_10153002205624265_4544638089958429298_n.jpg?oh=e82661d538bff26e9b529024329f9c42&oe=55948B63&__gda__=1435630072_674d75534e2151dcac7de09da7b03062","is_silhouette":false,"width":200,"height":200} at data of type org.json.JSONObject cannot be converted to JSONArray

这是jsonObject

{"data":{"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xaf1\/v\/t1.0-1\/p200x200\/10420230_10153002205624265_4544638089958429298_n.jpg?oh=e82661d538bff26e9b529024329f9c42&oe=55948B63&__gda__=1435630072_674d75534e2151dcac7de09da7b03062","is_silhouette":false,"width":200,"height":200}}

我做错了什么?? URL 是否有可能出错?因为如果我尝试:

JSONObject json = new JSONObject();
json.put("url", "https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-xaf1\/v\/t1.0-1\/p200x200\/10420230_10153002205624265_4544638089958429298_n.jpg?oh=e82661d538bff26e9b529024329f9c42&oe=55948B63&__gda__=1435630072_674d75534e2151dcac7de09da7b03062");

我收到一个错误:Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \ ) 但这是我在回复中得到的,我无法更改它。

您 json 中的对象 "data" 不是数组。 而不是使用:

JSONArray array = jsonObject.getJSONArray("data");

尝试:

JSONObject jsonDataObject = jsonObject.getJSONObject("data");