protected final Object parseResponse(byte[] responseBody) throws JSONException { if (responseBody == null) { return null; } Object result = null; String jsonString = TextHttpResponseHandler.getResponseString(responseBody, getCharset()); if (jsonString != null) { jsonString = jsonString.trim(); if (this.useRFC5179CompatibilityMode) { if (jsonString.startsWith("{") || jsonString.startsWith("[")) { result = new JSONTokener(jsonString).nextValue(); } } else if ((jsonString.startsWith("{") && jsonString.endsWith("}")) || (jsonString.startsWith("[") && jsonString.endsWith("]"))) { result = new JSONTokener(jsonString).nextValue(); } else if (jsonString.startsWith("\"") && jsonString.endsWith("\"")) { result = jsonString.substring(1, jsonString.length() - 1); } } if (result == null) { return jsonString; } return result; }
@Override public void setRequestKey(String key) { super.setRequestKey(key); }