Java 类com.android.volley.ParseError 实例源码

项目:super-volley    文件:BaseRequest.java   
@Override
protected com.android.volley.Response<String> parseNetworkResponse(NetworkResponse response) {
    this.statusCode = response.statusCode;
    this.responseHeaders = response.headers;
    /* Get the response data */
    try {
        String json = "";
        if (response.data != null) {
            json = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        }
        String log = "%1$s\nResponse code: %2$s\nResponse body: %3$s";
        VolleyLog.v(log, getUrl(), statusCode, json);
        if (statusCode >= 200 && statusCode < 300) {
            /* Return the parsed result in a response wrapper */
            return shouldCache() ?
                    success(json, parseIgnoreCacheHeaders(response)) :
                    success(json, parseCacheHeaders(response));
        } else {
            return error(new ServerError(response));
        }
    } catch (UnsupportedEncodingException e) {
        return error(new ParseError(e));
    }
}
项目:GeekZone    文件:BaseImageRequest.java   
/**
 * The real guts of parseNetworkResponse. Broken out for readability.
 */
private Response<Bitmap> doParse(NetworkResponse response) {
    byte[] data = response.data;
    BitmapFactory.Options decodeOptions = new BitmapFactory.Options();
    Bitmap bitmap = null;
    if (mMaxWidth == 0 && mMaxHeight == 0) {
        if (mDecodeConfig != null) {
            decodeOptions.inPreferredConfig = mDecodeConfig;
        }
        bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, decodeOptions);
    } else {
        bitmap = ImageUtils.compressBitmap(data, mMaxWidth, mMaxHeight);
    }

    if (bitmap == null) {
        return Response.error(new ParseError());
    } else {
        return Response.success(bitmap, HttpHeaderParser.parseCacheHeaders(response));
    }
}
项目:dolores-android    文件:HttpUtil.java   
public static String checkErrorType(VolleyError error) {
    String str = "";
    if (error instanceof NoConnectionError) {
        str = ErrorCode.IS_NOT_NETWORK;
    } else if (error instanceof AuthFailureError) {
        str = ErrorCode.AUTH_FAILED;
    } else if (error instanceof TimeoutError) {
        str = ErrorCode.CONNECTION_TIMEOUT;
    } else if (error instanceof ParseError) {
        str = ErrorCode.PARSE_DATA_ERROR;
    } else if (error instanceof ServerError) {
        str = ErrorCode.SERVER_ERROR;
    } else if (error instanceof HttpError) {
        HttpError httpError = (HttpError) error;
        str = httpError.getMessage();
        if (TextUtils.isEmpty(str)) {
            str = ErrorCode.REQUEST_ERROR;
        }
    } else {
        str = ErrorCode.REQUEST_ERROR;
    }
    return str;
}
项目:SimpleRESTClientHandler    文件:BaseArrayJsonRequest.java   
@Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response)
{
    try
    {
        String jsonString =
                new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        return Response.success(new JSONArray(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e)
    {
        return Response.error(new ParseError(e));
    } catch (JSONException je)
    {
        return Response.error(new ParseError(je));
    }
}
项目:SimpleRESTClientHandler    文件:BaseJsonRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response)
{
    try
    {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers));
        //Allow null
        if (jsonString == null || jsonString.length() == 0)
        {
            return Response.success(null, HttpHeaderParser.parseCacheHeaders(response));
        }
        return Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e)
    {
        return Response.error(new ParseError(e));
    } catch (JSONException je)
    {
        return Response.error(new ParseError(je));
    }
}
项目:SimpleRESTClientHandler    文件:BaseMultipartJsonRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response)
{
    try
    {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e)
    {
        return Response.error(new ParseError(e));
    } catch (JSONException je)
    {
        return Response.error(new ParseError(je));
    }
}
项目:SimpleRESTClientHandler    文件:BaseMultipartJsonArrayRequest.java   
@Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response)
{
    try
    {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONArray(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e)
    {
        return Response.error(new ParseError(e));
    } catch (JSONException je)
    {
        return Response.error(new ParseError(je));
    }
}
项目:VolleyX    文件:GsonRequest.java   
@Override
protected Response<T> parseNetworkResponse(NetworkResponse response) {
    if (mType == null && mJavaClass == null) return Response.error(new ParseError());
    try {
        String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        T parsedGSON = null;
        if (mType != null) {
            parsedGSON = mGson.fromJson(jsonString, mType);
        } else {
            parsedGSON = mGson.fromJson(jsonString, mJavaClass);
        }
        return Response.success(parsedGSON,
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JsonSyntaxException je) {
        return Response.error(new ParseError(je));
    }
}
项目:minhaeiro    文件:MinhaeiroErrorHelper.java   
public static String getMessage(VolleyError error){
    if (error instanceof TimeoutError) {
        return TIME_OUT;
    } else if(error instanceof NoConnectionError) {
        return NO_CONNECTION;
    } else if (error instanceof AuthFailureError) {
        return AUTH_FAILURE;
    } else if (error instanceof ServerError) {
        return SERVER;
    } else if (error instanceof NetworkError) {
        return NETWORK;
    } else if (error instanceof ParseError) {
        return PARSE;
    } else{
        return DEFAULT;
    }
}
项目:yun2win-sdk-android    文件:MyRequest.java   
/**
     * 数据返回
     */
    @Override
    protected Response<T> parseNetworkResponse(NetworkResponse response) {
        try {
            String strRue = new String(response.data, "UTF-8");
//            if (BuildConfig.DEBUG)
//                Log.d(TAG, xml);
            if (strRue.contains("error")) { //server返回错误
                ServerErrorResult serverError = mGson.fromJson(strRue,ServerErrorResult.class);
                Response.error(new MyErrorMessage(serverError.getStatus(),serverError.getMessage()));
            }
            return Response.success(mGson.fromJson(strRue,mClazz),HttpHeaderParser.parseCacheHeaders(response));
        } catch (Exception e) {
            e.printStackTrace();
            return Response.error(new ParseError(e));
        }
    }
项目:RealArchitecture    文件:VolleyRequest.java   
@Override
protected Response<T> parseNetworkResponse(NetworkResponse response) {

    try {
        Map<String, String> headers = response.headers;
        // TODO: 16/6/1 可以处理网络返回头信息

        String parsed = "";
        if (response.data != null && response.data.length > 0) {
            parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers, "utf-8"));
        }
        T map = gson.fromJson(parsed,
                new TypeToken<T>() {
                }.getType());

        return Response.success(map, HttpHeaderParser.parseCacheHeaders(response));
    } catch (Exception je) {
        return Response.error(new ParseError(je));
    }

}
项目:RestVolley    文件:RVImageRequest.java   
/**
 * The real guts of parseNetworkResponse. Broken out for readability.
 */
private Response<Bitmap> doParse(NetworkResponse response) {
    Bitmap bitmap = null;
    if (response instanceof StreamBasedNetworkResponse) {
        InputStream bitmapStream = ((StreamBasedNetworkResponse) response).inputStream;
        if (bitmapStream != null) {
            //parse bitmap stream
            bitmap = doParseStreamSafe(bitmapStream, ((StreamBasedNetworkResponse) response).contentLength);
        } else {
            //parse bitmap bytes
            bitmap = doParseBytes(response.data);
        }
    } else {
        //parse bitmap bytes
        bitmap = doParseBytes(response.data);
    }

    if (bitmap == null) {
        return Response.error(new ParseError(response));
    } else {
        return Response.success(bitmap, null);
    }
}
项目:Sxumiro_AndroidClient    文件:Request4FreshNewsDetail.java   
@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {

    try {
        String resultStr = new String(response.data, HttpHeaderParser.parseCharset(response
                .headers));
        JSONObject jsonObject = new JSONObject(resultStr);

        if (jsonObject.opt("status").equals("ok")) {
            JSONObject contentObject = jsonObject.optJSONObject("post");
            return Response.success(contentObject.optString("content"), HttpHeaderParser.parseCacheHeaders
                    (response));
        } else {
            return Response.success("error", HttpHeaderParser.parseCacheHeaders(response));
        }

    } catch (Exception e) {
        e.printStackTrace();
        return Response.error(new ParseError(e));
    }
}
项目:para-client-android    文件:ParaRequest.java   
@Override
@SuppressWarnings("unchecked")
protected Response<T> parseNetworkResponse(NetworkResponse response) {
    try {
        if (response != null && response.data != null && response.data.length > 0) {
            if (ClientUtils.isBasicType(type)) {
                return (Response<T>) Response.success(new String(response.data, "UTF-8"),
                        HttpHeaderParser.parseCacheHeaders(response));
            } else {
                return Response.success((T) ClientUtils.getJsonReader(type).
                        readValue(response.data), HttpHeaderParser.parseCacheHeaders(response));
            }
        } else {
            return Response.success(null, HttpHeaderParser.parseCacheHeaders(response));
        }
    } catch (Exception e) {
        logger.error("JSON parsing error", e);
        return Response.error(new ParseError(e));
    }
}
项目:guokr-android    文件:SearchModelImpl.java   
@NonNull
private Response<List<SearchEntry>> parseResponse(NetworkResponse response) {
    try {
        String html = new String(response.data, parseCharset(response.headers));
        Document document = Jsoup.parse(html);
        Elements elements = document.getElementsByClass("title-detail");
        List<SearchEntry> searches = new ArrayList<>();
        for (Element element : elements) {
            Element item = element.child(0);
            SearchEntry search = new SearchEntry();
            search.url = "http://m.guokr.com" + item.attr("href");
            search.content = item.html();
            search.datetime = element.child(1).child(1).attr("datetime");
            searches.add(search);
        }
        onParseResult(searches);
        return Response.success(searches, parseCacheHeaders(response));
    } catch (Exception e) {
        return Response.error(new ParseError(e));
    }
}
项目:fakeweibo    文件:CatnutArrayRequest.java   
@Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString =
                new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        Response<JSONArray> success = Response.success(new JSONArray(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
        if (mProcessor != null) {
            // do in background...
            mProcessor.asyncProcess(mContext, success.result);
        }
        return success;
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    } catch (Exception ex) {
        return Response.error(new VolleyError(ex));
    }
}
项目:fakeweibo    文件:CatnutRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString =
                new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        Response<JSONObject> success = Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
        if (mProcessor != null) {
            // do in background...
            mProcessor.asyncProcess(mContext, success.result);
        }
        return success;
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    } catch (Exception ex) {
        Log.e(TAG, "process error!", ex);
        return Response.error(new VolleyError(response));
    }
}
项目:GitHub    文件:JsonObjectRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:GitHub    文件:JsonArrayRequest.java   
@Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONArray(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:GitHub    文件:ImageRequest.java   
@Override
protected Response<Bitmap> parseNetworkResponse(NetworkResponse response) {
    // Serialize all decode on a global lock to reduce concurrent heap usage.
    synchronized (sDecodeLock) {
        try {
            return doParse(response);
        } catch (OutOfMemoryError e) {
            VolleyLog.e("Caught OOM for %d byte image, url=%s", response.data.length, getUrl());
            return Response.error(new ParseError(e));
        }
    }
}
项目:GitHub    文件:JsonObjectRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:GitHub    文件:JsonArrayRequest.java   
@Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONArray(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:GitHub    文件:ImageRequest.java   
@Override
protected Response<Bitmap> parseNetworkResponse(NetworkResponse response) {
    // Serialize all decode on a global lock to reduce concurrent heap usage.
    synchronized (sDecodeLock) {
        try {
            return doParse(response);
        } catch (OutOfMemoryError e) {
            VolleyLog.e("Caught OOM for %d byte image, url=%s", response.data.length, getUrl());
            return Response.error(new ParseError(e));
        }
    }
}
项目:publicProject    文件:JRYGRequest.java   
@Override
protected Response<T> parseNetworkResponse(NetworkResponse response) {
    // TODO Auto-generated method stub
    try {
        CommonLog.d("请求成功:statusCode:" + response.statusCode);
        String jsonStr = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        CommonLog.d(url + "返回:" + jsonStr);
        return Response.success(JSON.parseObject(jsonStr, mClazz), HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        CommonLog.d("请求失败!");
        return Response.error(new ParseError(e));
    }
}
项目:publicProject    文件:JsonObjectRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:publicProject    文件:JsonArrayRequest.java   
@Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONArray(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:publicProject    文件:ImageRequest.java   
@Override
protected Response<Bitmap> parseNetworkResponse(NetworkResponse response) {
    // Serialize all decode on a global lock to reduce concurrent heap usage.
    synchronized (sDecodeLock) {
        try {
            return doParse(response);
        } catch (OutOfMemoryError e) {
            VolleyLog.e("Caught OOM for %d byte image, url=%s", response.data.length, getUrl());
            return Response.error(new ParseError(e));
        }
    }
}
项目:TYT    文件:JsonObjectPostRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        return Response.success(new JSONObject(jsonString), HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:AndroidCrossPromotion    文件:CustomRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers));
        return Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:ease-volley-wrapper    文件:EaseBaseRequest.java   
@Override
protected Response<EaseResponse<T>> parseNetworkResponse(NetworkResponse response) {
    try {
        String json = new String(response.data, HttpHeaderParser.parseCharset(response.headers));

        EaseResponse<T> allayResponse;

        if (mTypeToken instanceof EaseStringType && ((EaseStringType) mTypeToken).getActualType().equals(String.class)) {
            allayResponse = new EaseResponse<>();
            allayResponse.setStatusCode(response.statusCode);
            JsonObject object = new JsonParser().parse(json).getAsJsonObject();
            allayResponse.setDescription(parseJsonKey(object, "result_description", ""));
            // Safe cast to type <T> as both T and data are of type String.
            //noinspection unchecked
            allayResponse.setData((T) parseJsonKey(object, "data", null));
        } else {
            allayResponse = new Gson().fromJson(json, mTypeToken.getType());
            allayResponse.setStatusCode(response.statusCode);

        }
        return Response.success(allayResponse, HttpHeaderParser.parseCacheHeaders(response));

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
        return Response.error(new ParseError(e));
    }
}
项目:Codeforces    文件:JsonObjectRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:Codeforces    文件:JsonArrayRequest.java   
@Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONArray(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:Codeforces    文件:ImageRequest.java   
@Override
protected Response<Bitmap> parseNetworkResponse(NetworkResponse response) {
    // Serialize all decode on a global lock to reduce concurrent heap usage.
    synchronized (sDecodeLock) {
        try {
            return doParse(response);
        } catch (OutOfMemoryError e) {
            VolleyLog.e("Caught OOM for %d byte image, url=%s", response.data.length, getUrl());
            return Response.error(new ParseError(e));
        }
    }
}
项目:papara-android    文件:PaparaRequest.java   
@Override
protected Response<String> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(jsonString,
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (Exception je) {
        return Response.error(new ParseError(je));
    }
}
项目:GeekZone    文件:JsonObjectRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:GeekZone    文件:JsonArrayRequest.java   
@Override
protected Response<JSONArray> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers, PROTOCOL_CHARSET));
        return Response.success(new JSONArray(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:GeekZone    文件:ImageRequest.java   
@Override
protected Response<Bitmap> parseNetworkResponse(NetworkResponse response) {
    // Serialize all decode on a global lock to reduce concurrent heap usage.
    synchronized (sDecodeLock) {
        try {
            return doParse(response);
        } catch (OutOfMemoryError e) {
            VolleyLog.e("Caught OOM for %d byte image, url=%s", response.data.length, getUrl());
            return Response.error(new ParseError(e));
        }
    }
}
项目:GeekZone    文件:BaseImageRequest.java   
@Override
protected Response<Bitmap> parseNetworkResponse(NetworkResponse response) {
    // Serialize all decode on a global lock to reduce concurrent heap usage.
    synchronized (sDecodeLock) {
        try {
            return doParse(response);
        } catch (OutOfMemoryError e) {
            VolleyLog.e("Caught OOM for %d byte image, url=%s", response.data.length, getUrl());
            return Response.error(new ParseError(e));
        }
    }
}
项目:FlyHttp    文件:CustomJsonRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString = new String(response.data,
                HttpHeaderParser.parseCharset(response.headers));
        return Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}
项目:iosched-reader    文件:JsonObjectRequest.java   
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
    try {
        String jsonString =
            new String(response.data, HttpHeaderParser.parseCharset(response.headers));
        return Response.success(new JSONObject(jsonString),
                HttpHeaderParser.parseCacheHeaders(response));
    } catch (UnsupportedEncodingException e) {
        return Response.error(new ParseError(e));
    } catch (JSONException je) {
        return Response.error(new ParseError(je));
    }
}